问题描述
我对reflow + repaint之间的区别有点不清楚(如果有任何差别)
I'm a little unclear on the difference between reflow + repaint (if there's any difference at all)
似乎回流可能会改变各种DOM的位置元素,其中重绘只是渲染一个新对象。例如。删除元素时会发生重排,更改颜色时会发生重绘。
Seems like reflow might be shifting the position of various DOM elements, where repaint is just rendering a new object. E.g. reflow would occur when removing an element and repaint would occur when changing its color.
这是真的吗?
推荐答案
这篇文章似乎涵盖了重排与重绘性能问题
This posting seems to cover the reflow vs repaint performance issues
至于定义,来自该帖子:
As for definitions, from that post:
此示例包括
outline
, visibility
,背景
,
或颜色
。根据Opera的说法,重绘是
昂贵,因为浏览器必须
验证DOM树中所有其他
节点的可见性。
Examples of this include outline
, visibility
, background
, or color
. According to Opera, repaint is expensive because the browser must verify the visibility of all other nodes in the DOM tree.
重排是
对性能
更为关键,因为它涉及
影响
页面(或整个页面)部分布局的更改)。
A reflow is even more critical to performance because it involves changes that affect the layout of a portion of the page (or the whole page).
导致回流的示例包括:添加或删除内容,显式或隐式更改 width
, height
, font-family
, font-size
等等。
Examples that cause reflows include: adding or removing content, explicitly or implicitly changing width
, height
, font-family
, font-size
and more.
在
这篇关于回流和重绘之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!