I'm a little unclear on the difference between reflow + repaint (if there's any difference at all)
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.
Is this true?
Here is another great post: http://blog.letitialew.com/post/30425074101/repaints-and-reflows-manipulating-the-dom
It also introduced when reflow occurs and how to minimize reflow.
Reflow happens when there is a change to the DOM layout. Reflow is very expensive computationally as dimensions and positions of page elements must be calculated again, then the screen will be repainted.
Example of something that will cause reflow
The above code is very inefficient, causing 100 reflow processes for every new paragraph element appended.
You can mitigate this computationally stressful process by using
.createDocumentFragment()
The above code will now instead only use the reflow process 1x for the creation of 100 new paragraph elements.
Repaint is merely the changing of pixels on the monitor, while still taxing it is the lesser of two evils, since a reflow includes a repaint in its procedure.
In my opinion, repaint just affects the DOM itself, but reflow affects the whole page.
Repaint occurs when some changes which only its skin styles, such as color and visibility.
Reflow occur when the page of DOM changes its layout.
Recently I found a site can search which attribute will trigger repaint or reflow. http://csstriggers.com/
This posting seems to cover the reflow vs repaint performance issues
http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/
As for definitions, from that post:
Learn which css-properties effect repaint and review at http://csstriggers.com