简体   繁体   English

DomContentLoaded事件是否暗示要构建DOM树或渲染树?

[英]Does the DomContentLoaded event imply construction of DOM tree or render tree?

When I profile my app the event is raise 1.5 second but the first pixels appear much later. 当我分析我的应用程序时,事件将触发1.5秒,但第一个像素出现的时间要晚得多。 This could imply that the event only stands for DOM tree construction. 这可能意味着该事件仅代表DOM树构造。 But this tutorial has me slightly confused now 但是现在这个教程让我有些困惑

https://developers.google.com/web/fundamentals/performance/critical-rendering-path/analyzing-crp https://developers.google.com/web/fundamentals/performance/critical-rendering-path/analyzing-crp

The DOMContentLoaded event is fired when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading . 当初始HTML文档已完全加载和解析without waiting for stylesheets, images, and subframes to finish loading时,将触发DOMContentLoaded事件。

MDN Link MDN连结

i have encountered the same question, so i read the article in google developers that you provide. 我遇到了同样的问题,因此我在您提供的Google开发人员中阅读了这篇文章。 However, i came into a different conclusion that it implies DOMContentLoaded event fires when dom tree is ready without waiting for cssom and render tree. 但是,我得出了一个不同的结论,即dom树准备就绪而无需等待cssom和渲染树时,就会触发DOMContentLoaded事件。 here is something from that article: 这是该文章的内容:

*An asynchronous script has several advantages:
The script is no longer parser blocking and is not part of the critical rendering path.
Because there are no other critical scripts, the CSS doesn't need to block the domContentLoaded event.
The sooner the domContentLoaded event fires, the sooner other application logic can begin executing.*

which means if script don't stop domtree parsing by set "async", domcontentloaded event won't even wait for css loading nor parsing to cssom. 这意味着如果脚本不通过设置“ async”来停止domtree解析,则domcontentloaded事件甚至不会等待CSS加载或解析为CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM