[defer]
You can add a defer attribute in <script> to tell the browser that this script does not need to be executed immediately, and the browser will execute this script after the document is fully loaded, which is equivalent to window.onload, but it is more flexible than window.onload.
The code copy is as follows:
<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 <script> tag - tells the browser that the script will not operate the DOM before the page is loaded, and the script will be downloaded in parallel with other resource files;
The async attribute of the <script> tag - HTML5 new asynchronous and parallel mode, the script will wait for the appropriate time to execute the code after the download is completed.
Have you any understanding of the [defer] and [async] properties of javascript? If you have any questions, please leave a message. Let's discuss it together.