Home >Web Front-end >JS Tutorial >Dynamically loading scripts to improve javascript performance_javascript tips

Dynamically loading scripts to improve javascript performance_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:58:35804browse

Through the Document Object Model (DOM), almost all content in HTML can be dynamically created with Javascript. The fundamental thing is that the <script> tag is no different from other elements in the page: they can all be referenced through the DOM, and they can all be moved, deleted, and even created in the document. It's very easy to create a New Year's <script> element using standard DOM methods: <br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="27506" class="copybut" id="copybut27506" onclick="doCopy('code27506')"><u>Copy the code</u></a></span> The code is as follows:</div> <div class="codebody" id="code27506"> <br><script type="text/javascript"> <br>var script=document.createElement("script"); <br>script.type="text/javascript"; <br> script.src="file1.js"; <br>document.getElementByTagName("head")[0].appendChild(script); <br></script>


This new creation The