HTML DOM Script async Property
-- Learning more than just technology, but dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
JavaScript Reference Manual
JavaScript Objects
- JavaScript Array Object
- JavaScript Boolean Object
- JavaScript Date Object
- JavaScript Math Object
- JavaScript Number Object
- JavaScript String Object
- JavaScript RegExp Object
- JavaScript Global Properties/Functions
- JavaScript Operators
- JavaScript Error
Browser Objects
DOM Objects
- HTML DOM Document Object
- HTML DOM Element Object
- HTML DOM Attribute Object
- HTML DOM Event Object
- HTML DOM Console Object
- CSSStyleDeclaration Object
- DOM HTMLCollection
HTML Objects
- <a>
- <area>
- <audio>
- <base>
- <blockquote>
- <body>
- <button>
- <canvas>
- <col>
- <colgroup>
- <datalist>
- <del>
- <details>
- <dialog>
- <embed>
- <fieldset>
- <form>
- <iframe>
- <frameset >
- <img>
- <ins>
- <input> - button
- <input> - checkbox
- <input> - color
- <input> - date
- <input> - datetime
- <input> - datetime-local
- <input> - email
- <input> - file
- <input> - hidden
- <input> - image
- <input> - month
- <input> - number
- <input> - range
- <input> - password
- <input> - radio
- <input> - reset
- <input> - search
- <input> - submit
- <input> - text
- <input> - time
- <input> - url
- <input> - week
- <keygen>
- <link>
- <label>
- <legend>
- <li>
- <map>
- <menu>
- <menuItem>
- <meta>
- <meter>
- <object>
- <ol>
- <optgroup>
- <option>
- <param>
- <progress>
- <q>
- <script>
- <select>
- <source>
- <style>
- <table>
- <td>
- <th>
- <tr>
- <textarea>
- <title>
- <time>
- <track>
- <video>
HTML DOM Script character Property
Script async Property
Example
Check if the script is executed asynchronously (as soon as it is available):
var x = document.getElementById("myScript").async
x output result:
true
Definition and Usage
The async property sets or returns whether a script should be executed asynchronously (as soon as it is available).
This property reflects the async attribute of the <script> tag.
Note: The async property only applies to external scripts (only when the src attribute is used).
Note: There are several ways to execute an external script:
- If async="async": The script is executed asynchronously with respect to the rest of the page (the script will be executed as soon as it is available while the page continues parsing)
- If async is not used and defer="defer": The script will be executed when the page has finished parsing
- If neither async nor defer is used: The script is read and executed immediately, before the browser continues parsing the page
Browser Support
All major browsers support the async property.
Note: IE 9 and earlier versions, and Opera 12 and earlier versions do not support the async property.
Syntax
Return the async property:
scriptObject.async
Set the async property:
scriptObject.async=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Specifies whether the script should be executed asynchronously (as soon as it is available). * true - The script is executed asynchronously (as soon as it is available). The script will be executed asynchronously as soon as it is available * false - The script is not 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 false. |
|---|
Related Articles
HTML Reference Manual: HTML <script> async Attribute
YouTip