Dynamic load scripts promote JavaScript performance

Source: Internet
Author: User
Tags object model

Dynamic load scripts can effectively improve JavaScript performance, here is a good example, you can refer to the following

With the Document Object Model (DOM), you can almost dynamically create all of the content in HTML with JavaScript. The point is that the,<script> tag does not differ from the other elements in the page: All can be moved, deleted, or even created in a document through a DOM reference. The standard Dom method makes it easy to create a new Year's <script> element: The code is as follows: <script type= "Text/javascript" > var script=  Document.createelement ("script");  Script.type= "Text/javascript";  Script.src= "File1.js";  Document.getelementbytagname ("Head") [0].appendchild (script); </script> this newly created <script> element loads the File1.js file. The file starts downloading when the element is added to the page. The point of this technique is that no matter when the download is started, the download and execution of the file does not block other processes on the page. You can even place the code in the page

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.