Aryan PrajapatKnowledge Contributor
Describe the role of deferred scripts in javascript.
Describe the role of deferred scripts in javascript.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
The defer Attribute:
The defer attribute tells the browser to continue to process the HTML and build DOM and does not wait till the script file is executed fully. The script loads “in the background”, and then runs later when the DOM is completely built.
For example:
The script is loaded asynchronously, the script file can be downloaded while the HTML document is still parsing, even if the file is fully downloaded before the HTML document is finished parsing, the script is not executed until the parsing is complete. Hence, scripts with a defer attribute will never block the page and always execute when the DOM is completely ready.