HTMLScriptElement: thuộc tính 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.
Thuộc tính defer của giao diện HTMLScriptElement là một giá trị boolean điều khiển cách thực thi tập lệnh. Với classic scripts, nếu thuộc tính defer được đặt thành true, tập lệnh ngoài sẽ được thực thi sau khi tài liệu đã được phân tích xong, nhưng trước khi sự kiện DOMContentLoaded được phát ra. Với module scripts, thuộc tính defer không có tác dụng.
Thuộc tính này phản ánh thuộc tính defer của phần tử <script>.
Giá trị
Một giá trị boolean.
Ví dụ
html
<script id="el" src="/example.js" defer></script>
js
const el = document.getElementById("el");
console.log(el.defer); // Kết quả: true
Thông số kỹ thuật
| Specification |
|---|
| HTML> # dom-script-defer> |