References

Beginner-friendly references for web development, with live, editable examples.

The HTML async attribute

Attribute All modern browsers Updated
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.
Where do head attributes apply?
On the metadata elements in the <head><meta>, <link>, <script> and <base>.
What is the difference between async and defer?
async runs a script as soon as it loads in no set order; defer runs scripts in order after the document is parsed.
Which elements use the async attribute?
It is an element-specific attribute, used on document head elements like <meta>, <link> and <script>.