Dynamically load scripts to improve javascript Performance
Dynamic Loading of scripts can effectively improve javascript performance. The following is a good example.
With the Document Object Model (DOM), almost all content in HTML can be dynamically created using Javascript. Basically, the <script> tag is no different from other elements on the page: It can be referenced by DOM and can be moved, deleted, or even created in the document. Using the standard DOM method, you can easily 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>
The newly created <script> element loads the file1.js file. The file starts to be downloaded when the element is added to the page. The focus of this technology is that the file download and execution process will not block other processes on the page at any time. You can even put the code in the