Method of of to double the loading speed of javascript to solve the problem of slow loading of JS


Usually our website will load some js code, statistics ah, Google advertising ah, baidu alliance ah, ali mother advertising code ah, A bunch of them, and eventually the page loads slowly, slowly.

Solution: switch to a js included method to double the loading speed of javascript.

Put the usual loading method: < Script SRC = “XXXX. Js” > < / script>

Change into:

<script type="text/javascript">
document.write("<scr"+"ipt src="xxx.js"></sc"+"ript>")
</script>

For example:

For example, the following is the application of the webmaster statistical code, although it was put at the bottom of the page, but still drag the page load schedule.

< 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 like this (still at the bottom of the page) :

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

It’s much faster.

Other js do the same, advertising, page effects… A few last words:

with < The script type = “text/javascript” > Document. Write (” < SCR ipt SRC = ”+” \ “XXX. Js \” > < ”+“/sc ript>” ) < / script>

The way, also can achieve on demand according to the conditions to load your JS file: < The script type = “text/javascript” > If (in a good mood) {document.write(”< SCR ipt SRC = ”+” \ “XXX. Js \” > < ”+“/sc ript>” )} < / script>

This way, if you’re in a bad mood, you won’t load your unwanted JS files.