Home > Article > Web Front-end > Methods to double the loading speed of javascript (solve the problem of slow JS loading speed)_javascript skills
Usually our website will load some js code, statistics, Google advertising, Baidu Alliance, Alimama advertising code,
A bunch of them, and finally the page loading speed is very slow.
Solution: Change the way js is included to double the loading speed of javascript.
Usual loading method:
changed to:
For example:
For example, the following is the webmaster statistics code applied for. Although it was placed at the bottom of the page in the past, it still slowed down the page loading progress.
We can change it to load like this (still placed at the bottom of the page):
Much faster.
Other js follows the same pattern, for advertising and page special effects. . .
Finally, a few nonsense words:
Use
can also be used to load the JS files you want on demand and conditionally:
In this way, if you are "in a bad mood", the JS files you don't want will naturally not be loaded.