Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the usage of defer attribute and async attribute in Javascript

云罗郡主
Release: 2018-10-17 15:13:39
forward
1896 people have browsed it

This article brings you a detailed explanation of the usage of defer attributes and async attributes in Javascript. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Why it is necessary to load js files asynchronously:

If asynchronous is not used, the document will block the download of other resources when loading js code, resulting in a blank page.

(1) When executing the js script placed at the top, the browser needs time to download the code of the external link file and execute it. This will cause an obvious delay and display a blank page, making the user unable to browse. content and cannot interact with the page.

(2) Although IE8, Firefox3.5, Safari4, and Chrome2 all allow parallel downloading of Javascript files, and the downloading process of the scripts will not affect each other, the loading of the page still needs to wait until all Javascript codes are downloaded and executed. to continue. Because of this, it is recommended to place the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template