JavaScript loading slow solution _javascript Tips

Source: Internet
Author: User
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:
Copy Code code as follows:

<script src= "Xxxx.js" ></script>

Change into:
Copy Code code as follows:

<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
Copy Code code 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 is the same, advertising, page effects ...
Finally, a few words of nonsense:

Use
Copy Code code as follows:

<<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:
Copy Code code as follows:

<<script type= "Text/javascript" >>
if (in good mood) {Document.writ E ("<<SCR" + "IPT src=" Xxx.js "></sc" + "Ript>>")}
<</script>>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.