So if you do 1 insert or 1000 in response to an event, it should only cause 1 reflow.
Animation on the other hand...
So if you do 1 insert or 1000 in response to an event, it should only cause 1 reflow.
Animation on the other hand...
This is all beside the point though: that example is for a specific part of their API. Keeping the example short by not adding more lines in order to optimise an unrelated area makes it a better example in the intended context even if not a complete show of general coding "best practise".
The original link's "better" option is bad for its own reason: it misses the glaring opportunity for reference caching. If you are going to call one example bad because of a missed optimisation make sure your counter example does miss an even more obvious one!
Remember kids: think before you post.
Any changes you make to the DOM/CSS are rolled up and happen together. Even changes to position, CSS transforms, etc.
That's why your effects code ends up having all those setTimeout(function(){keepGoing()}, 0); blocks in it. You need to chill from time to time and let the browser render what you've done already.