HTML Attributes
HTML <script> async Attribute
The async attribute lets an external script download in parallel and run as soon as it is ready.
The <script> async Attribute
async is a boolean attribute for the <script> element. It applies only to external scripts (those with a src). When present, the browser downloads the script in the background without pausing HTML parsing, then executes it immediately once the download finishes, which may interrupt parsing at that moment.
Syntax
Syntax: <script src="file.js" async></script>. Being boolean, async takes no value and is either present or absent. It has no effect on inline scripts.
<script src="https://example.com/analytics.js" async></script>| Value | Description |
|---|---|
| async | Download in parallel; execute as soon as ready, order not guaranteed |
| defer | Download in parallel; execute after parsing, in document order |
| (neither) | Download and execute immediately, blocking HTML parsing |
async scripts can run in any order and may execute before the DOM is fully parsed. Use async for independent scripts like analytics; use defer when execution order or a fully parsed DOM matters.
