HTML async Attribute
Example
<script src="demo/demo-async.js" async></script>
Meaning
The async attribute specifies that the browser might perform the fetch or execution of the script to be asynchronously from other activity in the page.
The meaning of this attribute versus the defer attribute with remote scripts in particular is quite unclear.
This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
Notes:
- async attribute is present: The script is downloaded in parallel to parsing the page, and executed as soon as it is available.
- defer attribute is present (and not async attribute): The script is downloaded in parallel to parsing the page, and executed after the page has finished parsing.
- Absence of async or defer: The script is downloaded and executed immediately, blocking parsing until the script is completed.
- The async attribute is only used for external scripts.
Standard Syntax
<script async>
Browser Support
Status
Applies to:
The async attribute can be used on the following element:
Attribute Values
Value | Description |
---|---|
async | This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. |