How to speed up your website?
It is terrible to realize that the success of the site, the pages of which you have filled with all sorts of information, decorated with many pictures, revived with the help of java-scripts, may be threatened due to its slow loading in the browser. But what to do if you just need every element of your web pages, every picture and every java-script is expensive. I propose to talk about this, namely, the methods of speeding up and optimizing your website. In my last article on this topic, we determined that the duration of loading pages of your site in the browser is determined by the number of requests that it generates, and the duration of the execution of these requests. We will not go into this topic again, but go directly to the tips on speeding up your website. These tips are especially suitable for owners of portals created on the basis of CMS, since the problems of fast loading of pages are most often found on such sites. So let’s get started: 1 tip. Optimization of style sheets Style sheets are very easy to use and should be used on all portals without exception. It often happens, especially when using CMS, that there are several such style sheets, and, consequently, the browser sends a request for each, which takes more time. In this regard, the first tip: merge all existing style sheets into one file. In addition, this resulting file can and should be optimized. Delete unnecessary lines, spaces, reduce information about colors – for example, replacing the white color in writing “#ffffff;” with a shorter “#fff;”, which ultimately affects the size of the resulting file and speeds up the process of loading it. Connecting style sheets in the page code is best in the HEAD tags area, that is, at the top of the page. 2 advice. Optimization of java-scripts When using java-scripts, it is often necessary to include the appropriate libraries for their proper operation. Often, these libraries are loaded directly from the site files, whereas you can load them in a more compressed form from specialized websites on the Internet, for example, from google services. In addition, the codes of the scripts themselves, however, as well as the connection strings of their libraries, as opposed to style sheets, should be placed at the very end of the pages of your site. This is due to the fact that the browser, meeting java-code on its way, stops loading the page until it completely processes the code. In addition, as is the case with style sheets, files with scripts are also worth merging. Here you will come to the aid of special services that perform the merger quickly and efficiently. 3 advice. Use css sprites In addition to images that are uploaded to your site dynamically, for example, during the execution of the php code, there are also many pictures that are announced in the css file of your site. For each of them also formed a separate request. But in the case of the use of technology css-sprites all the many requests for images can be replaced by one. The essence of the method is that only one picture is created, in which several, usually up to 20, which were previously loaded one by one, are placed in certain positions with previously known coordinates. And now instead of lines with each picture connected, each time you write the same line calling one common one, created by us, and by specifying certain indents, or more simply, coordinates, indicate the location of that particular picture you need. Thus, we manage to reduce the number of browser requests from 20 to 1! 4 advice. Use the technology of caching pages on your site If your resource does not imply a constant change of content, you just need to use page caching technology. In this case, when the user re-accesses the pages of your site, the browser no longer needs to send requests to the server each time, it is enough just to ask for information in the cache, which will significantly reduce the speed of loading your pages. Here, perhaps, are the main methods for optimizing a resource in order to accelerate it. In addition to these, there are many other ways, but about them, if you’re interested, we will talk next time. And let the pages of your site load with lightning speed!