Going to give FastDom a spin
Layout Thrashing is when JavaScript violently writes, then reads, from the DOM, multiple times causing document reflows.
FastDom is a small library I wrote to provide a common interface for batching of DOM read/write work. It massively speeds up DOM work using similarrequestAnimationFrame techniques described above.
Implications of using FastDom
By using FastDom you are making all DOM tasks asynchronous, that means you can't always make assumptions as to what state the DOM will be in. Work that was previously sync, may not have completed now it is async.
To work around this I like to use an event system to be more explicit about when work has finished, and responding only when I know DOM work I'm dependent on is complete.
Also we are increasing the amount of code we have to write to effectively get the same amount of work done. Personally I think this is a small price to pay for a dramatic increase in performance.
h/t Hacker News









