Method for doubling javascript loading speed (solving the problem of slow JS loading speed), javascriptjs
Normally, our website will load some js Code, statistics, google ads, Baidu consortium, alimama advertising code,
The page loading speed was slow and slow.
Solution: Use a js inclusion method to increase the loading speed of javascript.
Load the following methods:
<Script src = "xxxx. js"> </script>
Changed:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Document. write ("<scr" + "ept src = \" xxx. js \ "> </SC" + "ript> ")
</Script>
For example:
For example, the following is the statistic code of the requested Webmaster. Although it was previously placed at the bottom of the page, 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 replace it with this method for loading (either at the bottom of the page ):
Copy codeThe Code 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>
The speed is much faster.
Other js files, such as Ad files and special page effects...
Finally, let's talk a few nonsense words:
Use
<Script type = "text/javascript">
Document. write ("<scr" + "ept src = \" xxx. js \ "> </SC" + "ript> ")
</Script>
You can also load the JS file as required:
<Script type = "text/javascript">
If (good mood) {document. write ("<scr" + "ERT src = \" xxx. js \ "> </SC" + "ript> ")}
</Script>
In this way, if you are in a bad mood, you will naturally not load JS files you don't want.