The HTML async attribute
Quick answer
The HTML async attribute downloads the script in parallel and runs it as soon as it is ready, without blocking parsing. It is used on the <script> element.
Overview
The async attribute downloads the script in parallel and runs it as soon as it is ready, without blocking parsing. It applies to the <script> element.
Use async for independent scripts (like analytics) where execution order does not matter. Use defer when order matters or the script needs the parsed DOM.
Syntax
<script src="analytics.js" async></script>
Values
| Value |
|---|
| A boolean attribute — present or absent. |
Best practices
- Declare the character encoding with <meta charset="utf-8"> first in the <head>.
- Load scripts with defer (or as modules) so they do not block parsing.
- Protect third-party resources with integrity and crossorigin (Subresource Integrity).
- Use resource hints like preload deliberately, paired with the right as value.
Frequently asked questions
What does the async attribute do?
Loads and runs a script asynchronously.