The async attribute on a <script> with src fetches the file in parallel with HTML parsing and runs it as soon as it is available.
It is a boolean attribute. Use it for independent scripts (analytics, ads, widgets). Prefer defer when order matters or the script needs the full DOM. See also type="module".
Baseline · Widely available.
Not deprecated. Stable across modern browsers since about July 2015.
Needs src (classic scripts).
On inline classic scripts, async has no effect. If both async and defer are set, async wins.
Syntax
HTML Syntax
syntax.html
<script src="file.js" async></script>
Boolean form: write the name alone. async="" or async="async" means the same thing.
Values
Attribute Values
async is boolean — presence turns the behavior on:
Value
Description
Try it
async (present)
Fetch in parallel; run as soon as ready. Order not guaranteed
Load a tiny external script (data URL) with or without async and watch the log order.
Simulates fetch timing with a short delay. Real network order can still vary with async.
Event log
Mode: async
Code
HTML Examples
Short, copy-ready snippets. Use Try It Yourself for a live editor.
Example 1 — External Script with async
Download in parallel; run when ready without blocking the HTML fetch.
HTML
<h1>Hello</h1>
<p id="status">Page HTML keeps parsing…</p>
<script async src="data:application/javascript,document.getElementById('status').textContent='Async script ran.'"></script>
<p>This paragraph is still in the HTML stream.</p>
src points at an external script (required for classic async).
async starts the download without pausing the parser for the fetch.
When ready, the script runs (may briefly pause rendering).
No order promise relative to other async scripts.
Example 2 — async vs defer
Same download idea — different run time and ordering rules.
HTML
<!-- Independent: run ASAP, order not guaranteed -->
<script async src="analytics.js"></script>
<!-- Needs DOM / order: run after parse, in document order -->
<script defer src="app.js"></script>
<script defer src="widgets.js"></script>
Three independent async loads — any finish order is valid.
Dependent libraries should use defer (or a bundler), not multiple async tags.
How It Works
Each async script races to download on its own.
Whoever finishes first may run first.
Safe when scripts are independent of each other and the DOM.
Unsafe for jQuery + plugins — use defer (or modules) instead.
Edge Cases & Pitfalls
Most bugs come from assuming order or putting async on inline scripts.
src
Ignored without src
Classic inline scripts ignore async. Move the code to an external file if you need this behavior.
order
No guaranteed execution order
Do not chain dependent libraries with multiple async tags. Use defer, modules, or a bundle.
both
async + defer → async wins
Spec: if both are present, the element acts as if only async is set.
DOM
May run before the DOM is ready
If the script queries elements below it, prefer defer or wait for DOMContentLoaded.
modules
Modules already defer by default
type="module" defers automatically. async on modules still means “run as soon as the graph is ready.”
Compatibility
Browser Support
async is an HTML attribute on <script> in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
async
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support async on external scripts.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet Explorer10+
Supported
asyncWidely supported
Bottom line: Safe to use for independent external scripts. Prefer defer when document order or full DOM access matters.
Remember
Key Takeaways
Role: fetch external scripts in parallel; run as soon as ready.
Boolean on <script src> — ignored for classic inline scripts.
vs defer: async = ASAP + unordered; defer = after parse + ordered.
Best for: independent analytics/ads — not dependent app chains.
One line:async loads scripts early without guaranteed order — use defer when order or the DOM matters.
Frequently Asked Questions
On an external script, async fetches the file in parallel with HTML parsing and runs it as soon as it is available. Execution order among multiple async scripts is not guaranteed.
Yes. Presence means true; absence means false. Writing async="async" or async="" is the same as async.
Use async for independent scripts (analytics, ads) that do not need DOM order. Use defer when scripts must run in document order after the HTML is parsed.
No for classic scripts. Without src, async has no effect. Use an external file (or a module script) when you need async behavior.
The element behaves as if only async is specified (async wins).
No. It is Baseline widely available and recommended for independent external scripts.