4 ms·
> if you iteratively call .appendChild the browser has to reflow every time that happens No, it doesn't. Not unless you do one of two things: 1) yield to the
by bzbarsky 10y ago
> if you iteratively call .appendChild the browser has to reflow every time that happens
No, it doesn't. Not unless you do one of two things: 1) yield to the event loop and wait for a refresh tick or 2) query layout information.
The usual perfomance cliff is when you do #2 interleaved with appendChild. Because then the browser really does need to reflow.
With React, what you get is the ability to queue up all your appends but keep asking for the _old_ layout information, without taking your appends into account. Sometimes that's what you want, sometimes it's not. It really depends on why you're asking for the layout information.