Preact rendering in a web worker
preact-worker-demo.surge.sh
preact-worker-demo.surge.sh
In this demo, all the UI thread is doing is receiving batches of small instructions to update the DOM. Stuff like "change the text content of element #12" (all elements get assigned an ID).
That said, this is just an experiment. I wanted to get a real sense of whether threading was something we should care about for DOM manipulation.
Some of the other uses typically are - sort of flow control between the thread and the worker, so that only sufficient VDOM operations are sent across the thread.
This basically leaves the UI thread to other things like GIF animations, redraw UI like buttons when user interacts with them, etc.
From a quick look, it seems like this demo is using a web worker (i.e. another thread) to chunk up the dom manipulations. There's also some code to prioritise dom elements that are in the viewport.
(As an aside, this submission would be better if it linked to a blog post explaining what's interesting about this, rather than just the demo itself)
(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
But... its entirely impractical... it supports NO IE (only edge) ... its easy to make a small, fast lib that doesnt have to handle IE at all..
[1]http://pascalopitz.github.io/unoffical-sonos-controller-for-...
There are plenty of libraries that officially support IE, even when there are problems in a few small cases. They usually just make sure these issues are publicized so people won't be surprised them.
Please consider how your feedback might affect the people giving their effort to offer an option to the community.