Aryan PrajapatKnowledge Contributor
What are the different ways to execute external scripts?
What are the different ways to execute external scripts?
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.
There are three different ways to execute external scripts,
async: The script is downloaded in parallel to parsing the page, and executed as soon as it is available even before parsing completes. The parsing of the page is going to be interuppted once the script is downloaded completely and then the script is executed. Thereafter, the parsing of the remaining page will continue.
The syntax for async usage is as shown below,
defer: The script is downloaded in parallel to parsing the page, and executed after the page has finished parsing.
The syntax for defer usage is as shown below,
Neither async or defer: The script is downloaded and executed immediately by blocking parsing of the page until the script execution is completed.
Note: You should only use either async or defer attribute if the src attribute is present.