Usually our website will load some JS code, statistics ah, Google ads Ah, Baidu Alliance Ah, Ali mother Advertising code Ah, a heap, finally make the page loading speed is very slow, very slow.
Solution: Change the way a JS contains, so that the JavaScript loading speed doubled.
To load the usual way:
The code is as follows |
Copy Code |
<script src= "Xxxx.js" ></script> |
Change into:
The code is as follows |
Copy Code |
<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:
The code is as follows |
Copy Code |
<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 is the same, advertising, page effects ...
Finally, a few words of nonsense:
Use
The code is as follows |
Copy Code |
<<script type= "Text/javascript" >> document.write ("<<SCR" + "IPT src=" Xxx.js "></sc" + "ript>>") <</script>> |
The way, but also to achieve on demand according to the conditions to load the JS file you want:
code is as follows |
copy code |
<< Script type= "Text/javascript" >> if (in good mood) {document.write ("<<SCR" + "IPT src=" Xxx.js "></sc" + ") Ript>> ")} <</script>> |