Loading and execution in JavaScript

Source: Internet
Author: User
JavaScript may operate the DOM tree of HTML documents, so browsers generally do not download JS files in parallel like parallel CSS files, which is caused by the particularity of JS files. Therefore, if your JavaScript wants to operate the DOM elements behind it, the browser will report an error saying that the object cannot be found because the HTML behind the JavaScript execution is blocked, there are no nodes behind the DOM tree. Undertake the loading and execution of JavaScript in the previous article "Introduction to browser rendering principles.

Generally, browsers have two major features for JavaScript execution:

1) execute immediately after loading

2) The execution will block subsequent content on the page (including page rendering and download of other resources)

Therefore, if multiple JS files are introduced, these JS files will be serialized and executed in sequence by the browser.

Because JavaScript may operate the DOM tree of HTML documents, browsers generally do not download JS files in parallel like parallel CSS files. This is caused by the special nature of JS files. Therefore, if your JavaScript wants to operate the DOM elements behind it, the browser will report an error saying that the object cannot be found because the HTML behind the JavaScript execution is blocked, there are no nodes behind the DOM tree.

Traditional Mode

When you write the following code:

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.