Usually, some js codes are loaded on our website, statistics, google advertising, Baidu Alliance, Alibaba Mom advertising codes,
A bunch of them, and the page loading speed is very slow in the end.
Solution: Change the method of js to double the loading speed of javascript.
Put the usual loading method:
<script src="xxxx.js"></script>
Change to:
The code copy is as follows:
<script type="text/javascript">
document.write("<scr"+"ipt src=/"xxx.js/"></sc"+"ript>")
</script>
For example:
For example, the following is the applied webmaster statistics code. Although it was placed at the bottom of the page in the past, it still dragged down the page loading progress.
<script src="http://s69.cnzz.com/stat.php?id=265381&web_id=265381&show=pic" language="JavaScript" charset="gb2312"></script>
We can change it to load in this way (alively placed at the bottom of the page):
The code copy is as follows:
<script type="text/javascript">
document.write("<scr"+"ipt src=/"http://69.cnzz.com/stat.php?id=2651&web_id=2681&show=pic/" language=/"JavaScript/" charset=/"gb2312/"></sc"+"ript>")
</script>
Much faster.
Other js are made in the same way, advertising, and page special effects. . .
Finally, a few nonsense:
use
<script type="text/javascript">
document.write("<scr"+"ipt src=/"xxx.js/"></sc"+"ript>")
</script>
The method can also implement the loading of the JS file you want on demand and on conditional basis:
<script type="text/javascript">
if ( good mood) {document.write("<scr"+"ipt src=/"xxx.js/"></sc"+"ript>")}
</script>
If you are in a bad mood, you will naturally not load the JS file you don't want.