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

  • 2020-03-30 04:34:27
  • OfStack

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

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 = " 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="" language="JavaScript" charset="gb2312"></sc"+"ript>")

It's much faster.

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

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

Related articles: