On our agency’s blog, we share not only soft knowledge, but also hard knowledge, in the form of numbers, with expressions and commands that are not familiar to anyone in the company, except for developers. Why? Because we believe that it is enough to make our readers aware of the existence of the concerned issues to plant the seed of curiosity. To motivate them to verify these issues in their companies and respond, if necessary. This is our goal.
In our country, we have faster and faster Internet connection and nobody likes to use websites that load for a very long time... Each user expects the website to load immediately. Sometimes a simple and small website can load indefinitely, which, in the case of e.g. e-commerce portals, may significantly impact a decision (or rather lack thereof) to purchase a product.
That's because the creators of those websites forgot about the basic principles.
When creating a website, the web developer must remember several rules that will allow him to speed up the created website. One of the basic principles is for all possible scripts to be placed asynchronically or at the very end of the HTML document. Thanks to this simple measure, we can save a lot of time needed for full start-up of the website.
When placing images on the website, remember about their optimisation. Thanks to software such as FileOptimizer, we can save a few dozen valuable kilobytes, which is reflected in reduction in loading time by additional milliseconds. Image optimisation does not have to entail loss of its quality. Most programs remove the so-called metadata, namely e.g. EXIF information storing data about the camera, graphic software, etc.
In order to check whether our measures yield appropriate results, we can use the Google tool - PageSpeed Insights. It allows us to see what should be improved on the website in order to shorten the loading time. The below figure presents results of a test performed before image optimisation (on the left), and the next one - after optimisation (on the right):
As you can see, the result has strongly improved.
The last thing that is worth noting is the .htaccess file in the main folder of the project. Thanks to the directives it contains we can specify certain principles on the part of the server, which will significantly accelerate operation of our website and quality of its use. One of the methods to shorten loading times is compression of data sent from the server to the browser. For this purpose, we can use the Apache server module - mod_deflate. Below, we present a sample configuration:
If mod_deflate is not active, we can use mod_gzip:
Other important directives associated with the optimisation of website loading speed are related to the mod_expires module:
The above code sets the active-time of particular types of files. When the user visits the website for the first time, particular resources (files) will be saved in the browser's cache for a specific period of time.
The above principles allowed for another improvement in the loading speed of our website:
As you can see, simple changes that are very quick to introduce can give excellent results. The aforementioned principles are worth remembering, and even more worth applying on your own websites. Sometimes little is needed to significantly improve the comfort of using a website, which - as we've suggested at the very beginning - may have visible impact on sales and profits of the company.