Skip to content

Commit

Permalink
Add a question about executing external scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheerj committed Jun 29, 2024
1 parent ca5e764 commit 2b74a14
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<script src="demo.js" async></script>
```
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
<script src="demo.js" defer></script>
```
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)**
<!-- QUESTIONS_END -->
### Coding Exercise
Expand Down

0 comments on commit 2b74a14

Please sign in to comment.