欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

When is event DOMContentLoaded triggered

程序员文章站 2022-06-09 18:26:07
...

When is event DOMContentLoaded triggered?

DOMContentLoaded 何时触发?

 

Once the user agent stops parsing the document, the user agent must run the following steps:

当客户端停止解析文档后, 必须执行以下几步:


1. Set the current document readiness to “interactive” and the insertion point to undefined.

设置当前文档的状态为“inactive” 并设置插入点为 undefined。


Pop all the nodes off the stack of open elements.

 


2. If the list of scripts that will execute when the document has finished parsing is not empty, run these substeps:
2.1 Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing has its “ready to be parser-executed” flag set and the parser’s Document has no style sheet that is blocking scripts.
2.2 Execute the first script in the list of scripts that will execute when the document has finished parsing.
2.3 Remove the first script element from the list of scripts that will execute when the document has finished parsing (i.e. shift out the first entry in the list).
2.4 If the list of scripts that will execute when the document has finished parsing is still not empty, repeat these substeps again from substep 1.

3. Queue a task to fire a simple event that bubbles named DOMContentLoaded at the Document. 

 

相关标签: DOMContentLoaded js