HTML <script> async Attribute
Example
The script will run asynchronously once it is available:
Browser Support
Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the async attribute.
Note: Internet Explorer 9 and earlier versions do not support the async attribute for the <script> tag.
Definition and Usage
The async attribute is a boolean attribute.
The async attribute executes the script asynchronously once it is available.
Note: The async attribute is only for external scripts (only when the src attribute is used).
Note: There are several ways to execute external scripts:
If
async="async": The script is executed asynchronously with the rest of the page (the script will be executed while the page continues to be parsed)If
asyncis not used anddefer="defer": The script will be executed when the page has finished parsingIf neither
asyncnordeferis used: The script is fetched and executed immediately, before the browser continues parsing the page
Differences Between HTML 4.01 and HTML5
The async attribute is new in HTML5.
Differences Between HTML and XHTML
In XHTML, attribute minimization is forbidden, and the async attribute must be defined as <script async="async">.