Home >Web Front-end >JS Tutorial >Solution to slow loading speed of Javascript_javascript tips

Solution to slow loading speed of Javascript_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:55:441045browse

Usually our website will load some js code, such as statistics, Google ads, Baidu Alliance, Alimama advertising code, etc., and finally the page loading speed will be very slow.
Solution: Change A js inclusion method doubles the loading speed of javascript.
Replace the usual loading method:

Copy the code The code is as follows:



Change to:
Copy code The code is as follows:



If you want to load multiple js, you can use the following method
Copy code The code is as follows:



Other js follow the same pattern, for advertising and page special effects. . .
A few more nonsense words at the end:

Use
to copy the code The code is as follows:

<>

, you can also load the JS file you want on demand and conditionally:
Copy code The code is as follows:

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