THE WORLD'S LARGEST WEB DEVELOPER SITE

Script async Property

❮ Script Object

Example

Find out if a script was executed asynchronously as soon as it was available:

var x = document.getElementById("myScript").async

The result of x will be:

true
Try it Yourself »

Definition and Usage

The async property sets or returns whether a script should be executed asynchronously as soon as it is available, or not.

This property reflects the async attribute of the <script> tag.

Note: The async attribute is only for external scripts (and should only be used if the src attribute is present).

Note: There are several ways an external script can be executed:

  • If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
  • If async is not present and defer is present: The script is executed when the page has finished parsing
  • If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
async Yes 10.0 Yes Yes Yes


Syntax

Return the async property:

scriptObject.async

Set the async property:

scriptObject.async = true|false

Property Values

Value Description
true|false Specifies whether a script should be executed asynchronously as soon as it is available, or not
  • true - The script will be executed asynchronously as soon as it is available
  • false - The script will not be executed asynchronously as soon as it is available

Technical Details

Return Value: A Boolean, returns true if the script is executed asynchronously as soon as it is available, otherwise it returns false

Related Pages

HTML reference: HTML <script> async attribute


❮ Script Object