Live data from Hacker News

WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

github.com

21–30 of 62 posts

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#21

Wow, the contortions we go through trying to make HTML into a full-blown native application platform, instead of writing native applications. I'm impressed, but good god do we spend a lot of time reinventing the wheel within the limitations of browser engines.

It's true. I'm grateful though whenever I need to use a computer that's not mine and need access to stuff.

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#22

Wow, the contortions we go through trying to make HTML into a full-blown native application platform, instead of writing native applications. I'm impressed, but good god do we spend a lot of time reinventing the wheel within the limitations of browser engines.

You're probably right, but there are no alternates, so people build what they want with what's available.

I'm no expert in native or web development, but I don't know of any native GUI framework that looks as good as browser rendering does, is free, is easy to distribute, and secure.

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#23
post #9

If this is exposing DOM operations in a Worker and then replicating them back to the real DOM in the main thread, what happens if 2 Workers try to make incompatible changes to the DOM at the same time?

I would like to imagine that this interfaces with a Display Locking[1] shim in order to batch DOM updates in order. In all likelyhood this isn't true and there are probably a few race conditions.

1. https://github.com/chrishtr/display-locking/blob/master/expl...

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#24

Wow, the contortions we go through trying to make HTML into a full-blown native application platform, instead of writing native applications. I'm impressed, but good god do we spend a lot of time reinventing the wheel within the limitations of browser engines.

It's true. I'm grateful though whenever I need to use a computer that's not mine and need access to stuff.

And the owner of the computer your using is probably grateful you simply went to a website rather than installing some unknown executable on his computer.

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#26

Wow, the contortions we go through trying to make HTML into a full-blown native application platform, instead of writing native applications. I'm impressed, but good god do we spend a lot of time reinventing the wheel within the limitations of browser engines.

I'm assuming you've never had to write a cross-platform native app...

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#28
post #3
post #2

So if I'm reading it right, it looks like it's trying to replicate the DOM interface almost exactly (but in a web worker)! Which means that any UI library should be able to plug into this system and run mostly off the main thread for most of the application's life, bringing JS to parity with a lot of "native" development where you do most of your work on a "main" thread, and only touch the UI thread when you want to…

doesn't the added vdom lead to redundancy?

No, in fact it's likely very beneficial. Virtual DOM is meant to avoid the overhead of interacting with the real DOM (reading and writing to the DOM is slow). Being inside a web worker means that you're still interacting through the DOM, just via a web worker now. So the cost of reading and writing to and from the DOM is still present, plus there's the added overhead of communicating with the UI thread. So vdom in this case makes a meaningful difference by allowing the thread to get more work done in a shorter amount of time.

If you, for instance, blew away the whole DOM and re-rendered it (e.g., setting `innerHTML`) on every state change, the cost is going to be far higher than just tweaking the few things that might need tweaking, like on a keypress. If you're not keeping a virtual DOM around, there's no way to know what the diff is between your new and previous state to be able to make those tweaks.

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#29
post #12
post #10

I don't quite understand how busy your page must be if you feel that you're held back by the performance of one thread with the DOM. You know, DOM isn't really for video games or realtime data visualization.

I think this is more useful from the perspective of, if you have some busy task and you need to get the data back into the DOM, what can you do? You either need to build a messaging layer, which was the defacto way, or use this. I have a few projects that could benefit from this, being able to put a progress bar in the DOM and have the worker update it in a clean API is pretty neat.

Often though, a better pattern for that is to have your "compute thread" not know anything about the UI - it just sends back packets of result data, or serialized model updates, which the view-model layer back in the "UI thread" uses to rerender.

If React's virtual DOM diffing is epxensive enough to be a bottleneck in some applications though, I could see an advantage to moving that off thread...

Re: WorkerDom – The Same DOM API and Frameworks You Know, but in a Web Worker

#30

WebWorkers: Same great JavaScript, now with concurrency bugs!

Maybe your new at this but at this point, I've learned not to laugh. SPAs, Node.js, VDOM, transpilers, and many other things sounded absurd at one point.
Post reply on HN