CSS Portal

HTML async Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
async
HTML AttributeThis attribute is supported by all modern browsers.
Updated 28th March 2024

Description

The async attribute is used in HTML to indicate that a script should be executed asynchronously as soon as it is available. This attribute can be added to the <script> tag to control the loading and execution of JavaScript files. Unlike the default behavior, where scripts are loaded and executed in the order they appear in the document, causing the parsing of the document to be blocked until the script is downloaded and executed, scripts with the async attribute are executed independently of the page's load process. This means that the page does not wait for the asynchronous script to load and execute, allowing the browser to continue parsing and rendering the rest of the document without interruption.

The async attribute is particularly useful for scripts that do not depend on other scripts and do not modify the DOM (Document Object Model) immediately upon loading. Including the async attribute in a script tag looks like this: <script async src="path/to/script.js"></script>. When a script is loaded with async, it's executed as soon as it is downloaded, which could be before or after the HTML document is fully parsed. This improves the loading performance of web pages but requires developers to be mindful of any dependencies between scripts or on the readiness of the DOM.

Syntax

<script src="URL" async>

Values

  • URLURL or path of the source file.

Applies To

Example

&lt;script async src="myscript.js"&gt;&lt;/script&gt;
Open in editor

Browser Support

The following information will show you the current browser support for the HTML async attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee