HTML DOM Script async attribute
Examples
Check whether the script is executed asynchronously (Once a script is available):
var x = document.getElementById("myScript").async
x The output is:
true
try it"
Definition and Usage
async property sets or returns whether asynchronous execution script (script once available).
This property reflects the async attribute <script> tag.
Note: async property applies only to external script (only when using the src attribute).
Note: There are several ways to perform an external script:
- If async = "async": script asynchronously with respect to the rest of the page execution (when the page continues to be parsed, the script will be executed)
- When the script execution will be completed parsing the page: If you do not use the async and defer = "defer"
- If neither use nor async defer: Before the browser to continue parsing the page, immediately read and execute scripts
Browser Support
All major browsers support async attribute.
Note: IE 9 and previous versions of Opera version 12 and earlier do not support async attribute.
grammar
Returns async attribute:
scriptObject .async
Set the async property:
scriptObject .async=true|false
Property Value
值 | 描述 |
---|---|
true|false |
规定是否异步执行脚本(一旦脚本可用)。
|
technical details
return value: | Boolean value that, if the asynchronous execution of the script (script once available), it returns true, otherwise returns false. |
---|
related articles
HTML Reference Manual: HTML <Script> the async attribute