Solution for slow loading of Javascript

  • 2020-03-30 02:20:42
  • OfStack

Usually our website will load some js code, statistics ah, Google advertising ah, baidu alliance ah, ali mother advertising code ah, a pile, finally make the page load 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> 

If you want to load more than one js, you can use the following method
 
<script type="text/javascript"> 

document.write("<scr"+"ipt src="xxx1.js"></sc"+"ript>") ; 
document.write("<scr"+"ipt src="xxx2.js"></sc"+"ript>") ; 
document.write("<scr"+"ipt src="xxx3.js"></sc"+"ript>") ; 
</script> 

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

with
 
<<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:
 
<<script type="text/javascript">> 
if (  In a good mood  ) {document.write("<<scr"+"ipt src="xxx.js"></sc"+"ript>>")} 
<</script>> 

Related articles: