4 ms·
I worked on a similar project a few years ago: https://github.com/canjs/worker-render https://github.com/canjs/worker-render. It could render jQuery apps in a w
by MatthewPhillips 8y ago
I worked on a similar project a few years ago: https://github.com/canjs/worker-render https://github.com/canjs/worker-render. It could render jQuery apps in a web worker, it was pretty neat.
The problems I ran into, and I suspect this project will run into many of the same things were:
1. Events are synchronous so to make them async you have to preventDefault them, send to the worker, and then send back and re-dispatch them (if the worker didn't preventDefault). This works ok for many events like 'click' but not at all for things like touch events.
2. The debugging experience in the worker is not very good. Things you take for granted like being able to do `document.querySelector('.app')` and get a pretty-printed DOM object in the debugger do not work when that object is a fake DOM-like object.
3. There are a lot of DOM APIs and they continuously grow. Trying to implement everything is impossible. Many things can't (like events described above) be implemented 1 to 1. So it's a constant game of whack-a-mole.
Of these problems #2 is the biggest though. Devtools has a lot of really nice integrations with the DOM that you just lose when you're not using the actual DOM. So users have to decide if the tradeoffs are worth it. AMP might have an advantage in this regard, since you literally have no other choice; use their worker DOM or you can't run your app at all.
- vincentriemer 8y agoWhen I decided to take a stab at something similar, I settled on a different approach in taking an existing asynchronous UI architecture, React Native, instead of just trying to proxy the DOM: https://github.com/vincentriemer/react-native-dom https://github.com/vincentriemer/react-native-dom I think it works better because the original framework wrestles with the same limitations you mention (though an upcoming rearchitecture doesn't), and while it is by no means perfect, some early results are promising: https://rndom-movie-demo.now.sh https://rndom-movie-demo.now.sh