HTMLScriptElement: defer property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The defer
property of the HTMLScriptElement
interface is a boolean value that controls how the script should be executed. For classic scripts, if the defer
property is set to true
, the external script will be executed after the document has been parsed, but before firing DOMContentLoaded
event. For module scripts, the defer
property has no effect.
It reflects the defer
attribute of the <script>
element.
Value
A boolean.
Examples
html
<script id="el" src="/example.js" defer></script>
js
const el = document.getElementById("el");
console.log(el.defer); // Output: true
Specifications
Specification |
---|
HTML # dom-script-defer |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
defer |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.