From 2b74a14ce8b5bec980da8c7f1dc85e1a19977c85 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 29 Jun 2024 20:52:33 +0800 Subject: [PATCH] Add a question about executing external scripts --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 0c9e2b2a..eaba9299 100644 --- a/README.md +++ b/README.md @@ -8709,6 +8709,31 @@ The execution context is created when a function is called. The function's code **[⬆ Back to Top](#table-of-contents)** + 463. ### What are the different ways to execute external scripts? + + There are three different ways to execute external scripts, + + 1. 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, + + ```html + + ``` + + 2. 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, + + ```html + + ``` + 3. 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. + + **[⬆ Back to Top](#table-of-contents)** + ### Coding Exercise