DEV Community

Discussion on: Why Efficient Hydration in JavaScript Frameworks is so Challenging

Collapse
 
redbar0n profile image
Magne

Maybe you could even offload Hydration to a separate thread (web worker) that runs in parallel with the HTML being streamed in.

github.com/BuilderIO/partytown

An initial script tag at the top of the page could set the JS framework off on a separate worker thread, and the framework would need to take in (or listen to) the HTML/DOM as it becomes available, and then hydrate it incrementally. Not sure how wise it is to rely on support for web workers, though.

Collapse
 
ryansolid profile image
Ryan Carniato

Maybe.. but I think we can just do better doing less work still. Party town is cool because what it does is super low priority, no one is waiting on it. But using a worker like this much slower for working with the DOM. Solutions are getting too fancy with deferring when we should just be focusing on doing less work. Resumable Hydration is great, Partial is great at mitigating it. Progressive has its usage but is very overrated.