How to speed up your site?
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. Style sheet optimization
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, therefore, 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 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 style sheets in the page code in the HEAD tag area, that is, at the top of the page.
2 tip. Java script optimization
When using java scripts, you often have to connect the appropriate libraries for them to work correctly. 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 applying 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 specifying certain 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 page caching technology. In this case, when the user repeatedly accesses the pages of your site, 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. In addition to the above, there are many other ways, but about them, if interested, we will talk next time.
And let the pages of your site load with lightning speed!