i am trying to reduce my webpage load time . When i am searching i come to this point preload css and javascript .
So i am trying to implement this
Preloading resources that are loaded directly in the HTML is useless. This is because the browser reads the preload at the same time as the actual resource reference.
Preloading is useful to reduce the length of your request waterfall. Imagine the following situation:
style.css
body {
background-image: url(myimage.png);
}
index.html
The process of loading the above page consists (roughly) of the following steps:
index.html
style.css
background-image
, download myimage.png
This means your request waterfall is index.html -> style.css -> myimage.png
.
By adding a preload for myimage.png
the browser can download the image earlier, so your request waterfall becomes:
index.html +-> style.css
+-> myimage.png
Instead of 3, it is now only 2 requests long, which means faster load times.
Some common ways are:
But to get a better overall view of the things you can improve you can use the Chrome Audit system (Lighthouse).