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 ());
console.log("load js2:" new Date().toLocaleTimeString());
Firebug 레코드를 살펴보겠습니다.
js2.js가 이전 버전이었지만 이를 볼 수 있습니다. 이지만, js1.js의 실행이 완료된 후에야 js2.js가 실행되기 시작합니다. 소스코드 다운로드
Statement:
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