1. <script> less tags should be better (although there are multiple, it will not cause the program to report an error), because each <script> tag will block the page rendering when the page is initially downloaded
2. <script> Tags should not be placed above the page as much as possible, and try to put it at the bottom of <body>, because every <script> execute, download the corresponding js files. The browser will wait for all JS/CSS Only download the page to display the page
3. When we need to import multiple JS files, in general, we write two <script src = "..." / />, in fact supporting one -time import multiple, such as: <script src = "file1.js & file2.js" />
4. There is a attribute in the <script> tag: Defer, which indicates that the script contained in this element will not modify the DOM, so the code can be delayed safely, but the attribute is only supported by IE4+and Firefox3.5+browser. Hope When you use it, if you use other browsers, you will be ignored directly. Use examples:
<script type = "text /javascript" src = "file1.js" defer />
, Test the verification verification of the DEFER attribute:
Copy code code as follows:
<script defer> alert ("defer"); </script>
<script> Alert ("Script"); </Script>
<script>
window.onload = function () {
alert ("load");
};
</script>
This code should execute the order under our normal understanding: Defer, Script, Load, but if the order on the browser supporting DEFER is: Script, Defer, and LOAD, it needs to be noted here: DEFER is not following the script behind script Execution, but being called before the online event processing.
Time is limited, so much record today