Browser parses the basic process
Browser parses the basic flow
reflow和repaint
reflow, the browser is calculated based on the place and the results will be determined on the basis of elements into a variety of styles.
repaint: After relfow complete, the browser according to the characteristics of each of these elements to draw again.
And reflow operation causes the repaint
The operation caused repaint
A change in the appearance of the elements, but does not change the layout of
visibility
outline
background color
Cause reflow of operation
Change the window size
Change the font
Add and delete style sheets
Changing content, such as user input text input box
Activation pseudo-class
Operating class attribute
DOM script operations
OffsetWidth computing and offsetHeight
Setting style properties
display: none trigger reflow, and visibility: hidden trigger repaint, because the position has not changed
To avoid and minimize the impact
Directly change the elements you want to change (avoided by acting on the child element of the parent element, but a direct role in the child element)
Yellow to avoid inline style
For animation elements, which set fixed or absolute position
Speed tradeoff smooth, slow, frequently reflow
Avoid table layout
Js avoid css contains expressions (only IE)
How to determine the elements of reflow or repaint
Use chrome developer tools Timeline:
Timeline
References: