HTMLStyleElement: blocking 属性
HTMLStyleElement 接口的 blocking 属性是一个字符串,指示在获取关键子资源时应阻止某些操作。
它反映了 <style> 元素的 blocking 属性。
值
一个字符串。必须是以空格分隔的下面列出的 blocking tokens 的列表,用于指示要阻止的操作
render-
阻止在屏幕上渲染内容。
注意:只有文档
<head>中的style元素才可能阻止渲染。默认情况下,当浏览器在解析过程中发现<head>中的style元素时,它会阻止渲染。如果此类style元素是通过脚本动态添加的,您还必须将blocking = "render"设置为才能阻止渲染。
示例
html
<style id="el" blocking="render">
p {
color: blue;
}
</style>
js
const el = document.getElementById("el");
console.log(el.blocking); // Output: "render"
规范
| 规范 |
|---|
| HTML # dom-style-blocking |
浏览器兼容性
加载中…