Traditionally, loading Javascript files uses the tag. <br>Like the following: <br><script type="text/javascript" src="example.js"> The tag is very Convenient, as long as you add the web page, the browser will read and run it. However, it has some serious flaws. <br> (1) Strict reading order. Since the browser reads Javascript files in the order in which <script> appears in the web page, and then runs them immediately, when multiple files depend on each other, the file with the least dependency must be placed first, and the one with the greatest dependency must be placed first. The file must be placed at the end, otherwise the code will report an error. <br> (2) Performance issues. The browser uses "synchronous mode" to load the <script> tag, which means that the page will be "blocked", waiting for the JavaScript file to be loaded before running the subsequent HTML code. When there are multiple <script> tags, the browser cannot read them at the same time. It must read one before reading the other, which causes the reading time to be greatly extended and the page response to be slow. <br>In order to solve these problems, you can use the DOM method to dynamically load Javascript files. <br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="78858" class="copybut" id="copybut78858" onclick="doCopy('code78858')"><u>Copy code</u></a></span> The code is as follows: </div> <div class="codebody" id="code78858"> <br> function loadScript(url){ <br> var script = document.createElement("script"); <br> script.type = "text/javascript"; <br> script.src = url; <br> document.body.appendChild(script); <br>} <br> </div> <br>The principle of this is that the browser instantly creates a <script> tag and then reads the Javascript file "asynchronously". This will not cause page blocking, but it will cause another problem: the Javascript file loaded in this way is not in the original DOM structure, so the callback functions specified in the DOM-ready (DOMContentLoaded) event and window.onload event are invalid for it. .