JavaScriptEasy
Describe the difference between <script, <script async and <script defer
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
All of these ways (<script>, <script async>, and <script defer>) are used to load and execute JavaScript files in an HTML document, but they differ in how the browser handles loading and execution of the script:
<script>is the default way of including JavaScript. The browser blocks HTML parsing while the script is being downloaded and executed. The browser will not continue rendering the page until the script has finished executing.<script async>downloads the script asynchronously, in parallel with parsing the HTML. Executes the script as soon as it is available, potentially interrupting the HTML parsing. Multiple<script async>tags do not wait for each other and execute in no particular order.<script defer>downloads the script asynchronously, in parallel with parsing the HTML. However, the execution of the script is deferred until HTML parsing is complete, in the order they appear in the HTML.
Here's a table summarizing the 4 ways of loading <script>s in an HTML document. Modern apps almost always use modules, which deserve their own row.
| Feature | <script> | <script async> | <script defer> | <script type="module"> |
|---|---|---|---|---|
| Parsing behavior | Blocks HTML parsing | Downloads in parallel; execution still blocks parsing | Downloads in parallel; execution deferred until after parsing | Downloads in parallel; execution deferred until after parsing |
| Execution order | In order of appearance | Not guaranteed | In order of appearance | In order of appearance, with each script's import dependencies resolved first |
| DOM dependency | No | No | Yes (waits for DOM) | Yes (waits for DOM) |
