2017-09-19 57 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這意味着。