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: