How to speed up your site?
It’s awful to realize that the success of the site, the pages of which you filled with all kinds of information, decorated with a lot of pictures, enlivened with java scripts, may be at risk due to its slow loading in the browser. But what if you just need every element of your web pages, every picture and every java-script is expensive.
That’s about it, namely about ways to speed up, optimize your site, I suggest today to talk. In my last article on this topic, we determined that the duration of loading the 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 delve into this topic again, but proceed directly to tips on speeding up your site.
These tips are especially suitable for owners of portals created on the basis of CMS, since the problems of fast page loading are most often found just on such sites. So let’s get started:
1 tip. Optimization of style sheets Style sheets are very convenient 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, therefore, the browser sends a request for each, which takes more time. In this regard, the first tip: merge all existing stylesheets into one file. In addition, this resulting file can and should be optimized.
Delete unnecessary lines, spaces, reduce color information – for example, replacing the white color in the spelling “#ffffff;” with the shorter “#fff;”, which in the end will affect the size of the received file and speed up the process of downloading it. It’s best to include stylesheets in the page code in the HEAD tag area, that is, at the top of the page.
2 tip. Optimization of java-scripts When using java-scripts it is often necessary to connect the appropriate libraries for their correct work.
Often these libraries are loaded directly from the site’s files, while you can load them in a more compressed form from specialized sites on the Internet, for example, from google services.
In addition, the codes of the scripts themselves, however, like the connection strings of their libraries, unlike style sheets, should be placed at the very end of the pages of your site. This is due to the fact that the browser, encountering java code in its path, stops loading the page until it processes this code completely. In addition, as is the case with style sheets, script files are also worth combining.
Here you will come to the rescue of special services that will perform the merger quickly and efficiently.
3 tip. Use css sprites In addition to the pictures that are loaded dynamically on your site, for example, during the execution of php code, there are also many pictures that are declared in the css file of your site. A separate request is also generated for each of them. But in the case of using css-sprite technology, the whole set of requests for pictures can be replaced with one single one.
The essence of the method is that only one picture is created, on which several, usually up to 20, which were previously loaded individually, are placed in certain positions with previously known coordinates. And now instead of lines with connecting each of the pictures, each time you write the same line with a call to one common line created by us, and by indicating specific indents, or more simply, coordinates, specify the location of that particular picture that you need.
Thus, we are able to reduce the number of browser requests from 20 to 1!
4 tip. Use the technology of caching pages on your site If your resource does not imply a constant change in content, you just need to use the technology of caching pages. In this case, when the user accesses the pages of your site again, the browser no longer needs to send requests to the server each time, but just ask for information in the cache, which will significantly reduce the loading speed of your pages. Here, perhaps, are the main methods for optimizing a resource in order to accelerate it.