Usually, some js codes are loaded on our website, statistics, google advertising, Baidu Alliance, Alibaba Mom advertising codes, and a bunch of them, which ends up making the page loading very slow, very slow.
Solution: Change the method of js to double the loading speed of javascript.
Put the usual loading method:
The code copy is as follows:
<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>
If you want to load multiple js, you can use the following method
The code copy is as follows:
<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 are made in the same way, advertising, and page special effects. . .
Finally, a few nonsense:
use
The code copy is as follows:
<<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:
The code copy is as follows:
<<script type="text/javascript">>
if ( good mood) {document.write("<<scr"+"ipt src="xxx.js"></sc"+"ript>>")}
<</script>>