HTMLScriptElement: defer プロパティ
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.
defer
は HTMLScriptElement
インターフェイスのプロパティで、スクリプトの実行方法を論理値で制御します。クラシックスクリプトの場合、defer
プロパティを true
に設定すると、外部スクリプトは文書が構文解析された後、DOMContentLoaded
イベントを発行する前に実行されます。モジュールスクリプトの場合、defer
プロパティは何の効果もありません。
これは <script>
要素の defer
属性を反映します。
値
論理値です。
例
html
<script id="el" src="/example.js" defer></script>
js
const el = document.getElementById("el");
console.log(el.defer); // 出力: true
仕様書
Specification |
---|
HTML # dom-script-defer |
ブラウザーの互換性
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.