Script defer Property
Find out if a script was executed when a page was finished parsing:
The result of x will be:
Definition and Usage
The defer property sets or returns whether a script should be executed when a page has finished parsing, or not.
This property reflects the defer attribute of the <script> tag.
Note: The defer 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
Return the defer property:
Set the defer property:
Specifies whether a script should be executed when the page has finished parsing, or not
|Return Value:||A Boolean, returns true if the script is executed when the page has finished parsing, otherwise it returns false|
HTML reference: HTML <script> defer attribute
❮ Script Object