how do you reduce the time of your site?
One of the most important things he saw from the model that bears the name of the site
Everything was better
In the middle of this, we will say how do you reduce the time of your site?
The time to load a site depends on many things, including the server itself
But there are small things, and you do not take time to change them, so you can reduce the time by a large percentage, and the most important of them are:
Reduce the size of files (such as the images on your site)
Reduce the number of files
lazy loading
We will focus more on the last two if you look at the pictures below
You will find the difference between the loading time after each step
The first picture is the site
The second picture is after I reduced the number of files
Next picture after I applied lazy loading
Ok, how do we do this, and why does it make a difference?
Let's talk about the number of files
You use a library to help make it work, jquery, animate.css, your design files, or javascript.
And every one of the files he followed on your site
The number of these files makes the server make a special request for each one to upload it to your site. The higher the number, the higher the number of requests, and this creates a download on the server.
And the real solution is very simple and most of those who use Vue, Angular or React
They have an automatic solution
It is the compilation of all these files in one file that needs a webpack
The first picture I had 48 requests of files for pictures for fonts and downloading took 21.5 seconds
The second picture is after I made the files of the style and javascript in the webpack and left them one file all.css and one all.js
I have 34 requests left and the download took 15.5 seconds (6 seconds, a difference of about 30% faster)
The second solution is Lazy Loading
The lazy loading simply is that you do not carry the images except when the user is close to their place, and this saves you that you do not have the needs of the user like this, you can't see the pictures in the footers or the one after the big scroll and the user will basically go to another page and be marginal
The solution is good, because you use the original html language, but its effect is very weak
The best solution is to use js library to do the work
In the picture No. 3, the loading time remains 11.3 instead of 15.5. The top of the requests is 26 instead of 34
But let me know that when the user downloads below the page, you will start uploading the pictures that you can't bear, so you will find the site the number of requests and the time increases the more you download (and the UX starts to be a little monster if the user downloads below faster than the speed of uploading pictures)