3. Use the sequential loading feature of JavaScript on the page to add HTML The external JS reference in the fragment is placed at the top pages2_4.htm:
You may think that the third method is unnecessary, but if you encounter such a need, you will know the importance of the third method.
Do not load this JS file on every page The caller does not know which JS files are associated with an HTML fragment ================== =========================================== About the order of JS Execution Features Some people may not be very clear about this feature, so I will illustrate it with an example.
console.log("start load js1 :" new Date().toLocaleTimeString()); // In the middle is a very long piece of JavaScript, as much as 12M console.log("end load js2:" new Date().toLocaleTimeString ());
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn