YouTip LogoYouTip

Prop Script Defer

# Script defer property [![Image 8: Script Object Reference](#) Script Object](#) ## Example Check if the script is executed when the page has finished parsing: var x = document.getElementById("myScript").defer The output of _x_ will be: true [Try it Yourself Β»](#) * * * ## Definition and Usage The defer property sets or returns whether the script should be executed after the page has finished parsing. This property reflects the defer attribute of the tag. **Note:** The defer 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 the rest of the page (the script will be executed while the page continues the 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 ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The defer property is supported by all major browsers. **Note:** Opera 12 and earlier versions do not support the defer property. * * * ## 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 after the page has finished parsing. * true - The script is executed after the page has finished parsing. * false - The script is not executed after the page has finished parsing. | ## Technical Details | Return Value: | A Boolean value. Returns true if the script is executed after the page has finished parsing, otherwise it returns false. | | --- | * * * ## Related Articles HTML Reference: (#) * * Script Object](#)
← Prop Script SrcProp Script Character β†’