We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
浏览器是多线程的
GUI
JavaScript
为了防止渲染出现不可预期的结果(js可能修改dom或css),GUI 渲染线程和JavaScript引擎线程互斥。
js
dom
css
HTML
DOM
Dom Tree
CSS
CSS Rule Tree
Render Tree
Reflow
Layout
Repaint
Display
GPU
元素新增和删除以及位置或大小改变会触发节点的回流(Reflow),之所以叫回流是因为浏览器默认的布局方式是流式布局。参考回流和重绘
style
class
will-change
translateZ
documentFragment
web worker
async
script
html
defer
DOMContentLoaded
你真的了解回流和重绘吗
The text was updated successfully, but these errors were encountered:
No branches or pull requests
浏览器多线程
浏览器是多线程的
GUI
渲染线程JavaScript
引擎线程为了防止渲染出现不可预期的结果(
js
可能修改dom
或css
),GUI
渲染线程和JavaScript
引擎线程互斥。渲染线程
HTML
构建DOM
树Dom Tree
CSS
构建 CSS 规则树CSS Rule Tree
CSS
规则树附加到DOM
树上,删除不可见元素,形成渲染树Render Tree
Reflow
或Layout
):计算每个元素盒子位置和大小Repaint
):根据元素的位置和大小,计算元素的绝对像素Display
):将绝对像素发给GPU
,将多个合成层合并,形成一个层。优化方式
js
操作dom
style
样式改变通过class
而不是手动修改GPU
加速渲染will-change
和translateZ
documentFragment
离线操作dom
web worker
中完成script defer和async
async
属性会异步下载script
,下载后立即执行,下载完成前不影响html
解析。defer
属性会异步下载script
,下载后延迟执行,等到html
解析完成,执行完成后触发DOMContentLoaded
事件async
是无序的,而defer
有序参考
你真的了解回流和重绘吗
The text was updated successfully, but these errors were encountered: