Home  >  Article  >  Web Front-end  >  [defer] and [async] attributes of js_javascript skills

[defer] and [async] attributes of js_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:30:181123browse

[defer]

You can add the defer attribute to <script> to tell the browser that this script does not need to be executed immediately. Then the browser will execute this script after the document is completely loaded, which is equivalent to window.onload, but it is better than window. .onload is more flexible. </p> <p></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="80846" class="copybut" id="copybut80846" onclick="doCopy('code80846')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code80846"> <br> <script defer="true"></script>

[async]

Load JavaScript using the async attribute so that the entire script can be loaded and executed asynchronously.

The defer attribute of the