Script deferProperty
Examples
Check whether the script is executed when the page has finished parsing:
var x = document.getElementById("myScript").defer
xThe result is:
true
Try it Yourself »
Definition and Usage
The defer property sets or returns whether the script is executed when the page has finished parsing.
This property reflects the defer attribute of the <script> tag.
Note:The defer attribute only applies to external scripts (only when the src attribute is used).
Note:There are several ways to execute external scripts:
- If async="async": the script is executed asynchronously relative to the rest of the page (the script will be executed 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 defer attribute.
Note:Opera 12 and earlier versions do not support the defer attribute.
Syntax
Return the defer property:
scriptObject.defer
Set the defer property:
scriptObject.defer=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Specifies whether the script should be executed when the page has finished parsing.
|
Technical Details
| Return Value: | A Boolean value, returns true if the script is executed when the page has finished parsing, otherwise returns false. |
|---|
Related Articles
HTML Reference:HTML <script> defer attribute
Other Extensions
Script Object