Home  >  Forum  >  JavaScript
Post New Query

Difference between async and defer in JavaScript



Asked on April 13, 2016
What is difference between async and defer in JavaScript?
When to use defer and when to use async?



Replied on April 13, 2016
<script async>: It is a boolean attribute and once set, script loading takes place parallel to HTML parser. Once script loading is finished, HTML parser is stopped and script execution started. Once script execution completed, HTML parser is started again. 

<script defer> : It is a boolean attribute and once set, script loading takes place parallel to HTML parser. Once script loading is completed, it waits for HTML parser completion. After HTML parser completed, script execution is started and completed.



Write Answer







©2019 concretepage.com | Privacy Policy | Contact Us