Use scriptin theDeferproperty.
Scriptin thedeferproperty by default isfalsethe.
In other words: If you are writing a script, adddeferproperty, the browser does not have to deal with it immediately when it downloads the script, but continues to download and parse the page, which improves the performance of the download.
There are many kinds of situations like this. Like you've defined a lot.JavaScriptvariable, or in a reference file (. Incwrite a lot of scripts that need to be processed, so you might want to include them in these scripts .deferproperties, it is certainly helpful to improve performance.
Examples are as follows:
<script language= "JavaScript" defer>
var object = new Object ();
....
</script>
Becausedeferproperty is default tofalse, then here<script language= "javascript" defer>Explicit Declarationdeferproperty is equivalent to<script language= "javascript" defer=true>
Declared thedeferproperty, you need to determine if there are other variables referencing thedefera variable in the script block, otherwise it will cause a script error to occur
Combining <body onload= "xx ()" >
And
<script defer= "Defer" >
XX ();
</script>
The JS will be executed after the page is loaded, including the IFRAME loading
How to execute JS after the page is fully loaded