Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

页面阻塞 #101

Open
lovelmh13 opened this issue Jul 5, 2021 · 0 comments
Open

页面阻塞 #101

lovelmh13 opened this issue Jul 5, 2021 · 0 comments

Comments

@lovelmh13
Copy link
Owner

快速记要:

  1. css 不会阻塞 DOM 解析,但会阻塞 DOM 渲染(与 DOM 树合成 Layout tree)
  2. js 会阻塞 DOM 解析,所以除非必要,js 都放到了 DOM 之后
  3. 浏览器遇到 <script> 且没有 defer 或 async 属性的标签时,会触发页面渲染,因而如果前面 CSS 资源尚未加载完毕时,浏览器会等待它加载完毕在执行脚本。

原来 CSS 与 JS 是这样阻塞 DOM 解析和渲染的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant