2017-09-19 54 views

回答

0

DOMContentLoaded事件被触发时,最初的HTML文档完全加载和分析,without waiting for stylesheets, images, and subframes to finish loading

MDN Link

+0

这并不涉及渲染,这是另一个单独的步骤。 – Xufox

+0

浏览器在解析第一个HTML元素后开始渲染页面。它当然不会等待DOM树完成,对于所有外部资源的加载都要少得多。 –

+0

是否有事件显示渲染树的构造?我不在乎图像,所以加载事件对我无用 – prk68

-1

我也遇到同样的问题,所以我读了您提供的谷歌开发者的文章。然而,我得出了一个不同的结论,即当dom树已经准备就绪而不等待cssom和渲染树时,它暗示DOMContentLoaded事件触发。 这里是那篇文章的内容:

*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.* 

如果脚本不停止集“异步”,domcontentloaded事件domtree解析甚至不会等待加载CSS解析,也不向cssom这意味着。