如何理解规范中脚本标签的术语"non-blocking"?

How to understand the term "non-blocking" of script tag in spec?

spec:

The third is a flag indicating whether the element will "non-blocking". Initially, script elements must have this flag set. It is unset by the HTML parser and the XML parser on script elements they insert. In addition, whenever a script element whose "non-blocking" flag is set has an async content attribute added, the element’s "non-blocking" flag must be unset.

抱歉,我不明白是什么means.There有一些问题是这样的:

1.

The third is a flag indicating whether the element will "non-blocking". Initially, script elements must have this flag set

"Initially" 表示 HTMLScriptElement class 中有一个 属性 名为 non-blocking 并且默认为 true 或表示它是 true 当在被 HTML 解析器解析之前创建或实例化的脚本元素?

2.

It is unset by the HTML parser and the XML parser on script elements they insert.

"insert"是指脚本元素通过document.writeinsert操作插入文档?

3.

In addition, whenever a script element whose "non-blocking" flag is set has an async content attribute added, the element’s "non-blocking" flag must be unset.

async链接到async attribute,但是有一个词"content",那么它到底是什么意思?从服务器或本地获取的属性或内容?

如果是content,是不是代表HTMLParser会在async content添加前继续解析script元素的后续字节?(我写了一些测试,我认为这是错误的)

4.And最重要,"non-blocking"是不是像我们平时说的那样阻塞IO,获取资源,更新布局,重绘等?还是有其他含义?还有规范说 "Initially, script elements must have this flag set",但我们经常认为 script 是 "blocking"(正是在执行时),所以当我第一次阅读这篇文章时我有疑问所以 now.Could 有人澄清我的有疑问?

5.Finally有没有spec的实现(我指的是可以方便调试的src代码)?我觉得基于chrome比较好,抱歉,我不是说其他不好,只因为我只装chrome.

  1. 我不区分。选择哪一个实现会产生什么功能差异?

  2. 插入操作。 document.write 没有插入到文档中。它将字符注入到解析器处理的输入字节流中。

  3. 在HTML5规范中,有两种类型的"attribute"。 "Content attribute" 和 "IDL attribute"。 "content attribute" 是您在标记中放置的内容:<script async> 是异步内容属性。 "IDL attribute" 是大多数人认为 JavaScript myScriptElement.async 中的 属性。

  4. 表示不阻塞解析器线程。解析器从输入流中获取字符并创建元素、文本节点对象等。当解析器被阻塞时,它会停止使用输入流中的字符。 (尽管它可能会在输入流中 look-ahead 猜测它是否会被要求获取其他资源,并推测性地获取它们)。当看到 </script> 标记时,如果未设置 non-blocking 标志,则解析器将不会从当前输入流中消耗任何进一步的字符,直到脚本被提取并 运行。这允许脚本包含 document.write 以将字符注入输入流,以便接下来对其进行解析。

  5. Chrome (blink) 和 Firefox (gecko) 都是开源的,但就我个人而言,我没有尝试详细检查任何一个代码库,所以无法告知它们有多难是。无论如何,这可能完全是个人喜好。