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 摘要。