javascript-tutorial / javascript-tutorial/en.javascript.info

some description not accurate in the article of 《onload-ondomcontentloaded》

未關閉
#1,842 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
HTML
星號
25.5k
分支
4k
PR 合併指標
30 天內沒有已合併 PR

描述

## article
article Link [《onload-ondomcontentloaded》](https://javascript.info/onload-ondomcontentloaded)

## may not accurate
> document.readyState becomes interactive right before DOMContentLoaded. These two things actually mean the same.

> interactive – the document is parsed, happens at about the same time as DOMContentLoaded, but before it.

## reason
if a page containers some "defer" script, then it will cost some time to execute the "defer" script after interactive but before DCL.

## Reference
https://calendar.perfplanet.com/2012/deciphering-the-critical-rendering-path/
>If you add a script and tag it with “defer”, then you unblock the construction of the DOM: the document interactive state does not have to wait for execution of JavaScript. However, note that this same script will be executed before DCL is fired. Further, recall that JavaScript may query CSSOM, which means that the DCL event may be held until the CSSOM is ready, at which point the script will be executed. In short: we’ve unblocked the “document interactive” state, but we’re still potentially blocking DCL.

https://html.spec.whatwg.org/multipage/dom.html#current-document-readiness
> The DOMContentLoaded event fires after the transition to "interactive" but before the transition to "complete", at the point where all subresources apart from async script elements have loaded.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

開啟連結的 onload-ondomcontentloaded 文章,並將其中引用的 readyState 與 DOMContentLoaded 描述,與 WHATWG 的 readiness 參考資料及 defer 指令碼說明進行比較。更新文章,使其區分轉換至 interactive 與稍後發生的 DOMContentLoaded 事件,然後根據這些參考資料核對修訂後的措辭。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。