3 ms·
Agreed. Someone submitted this before I got around to writing that post, heh. Synopsis: fake DOM in the worker w/ MutationObserver that sends batched changes up
by developit 10y ago
Agreed. Someone submitted this before I got around to writing that post, heh. Synopsis: fake DOM in the worker w/ MutationObserver that sends batched changes up to the UI thread. Event delegation to get things back into the worker. It's actually relatively straightforward, demo code is a mess though.
- jsprogrammer 10y agoIs it worth doing right?
- axemclion 10y agoThere are a bunch of other complexities too - things like (1) cancelling events which are synchronous, but web worker communication is async (2) What is the best serialization format ? I found JSON.stringify to be the fastest, but how to compress data better ? (3) How to batch the operations when you want to send info over from worker to the UI thread. The batch size should be small enough that it runs in 16ms, but large enough that you don't waste frame cycles. (4) Figuring out if it makes sense to spawn multiple workers to diff parts of the VDOM tree - similar to React Fiber