Home  >  Article  >  Web Front-end  >  Methods to double the loading speed of javascript (solve the problem of slow JS loading speed)_javascript skills

Methods to double the loading speed of javascript (solve the problem of slow JS loading speed)_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:27:301964browse

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:

Copy code The code is as follows:


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):

Copy code The code is as follows:


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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn