Live data from Hacker News

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

github.com

41–50 of 62 posts

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

#41
post #35
post #18

Earlier quoted context omitted.

Yes I know. Which is why I asked what happens if two Workers try to make incompatible changes at the same time. How does this library resolve conflicts when applying the changes from the fake DOM to the real one? In fact, this doesn't even require 2 Workers, you could get a conflict with a single Worker if you're also making DOM changes on the main thread.

This is like asking what happens if two different micro-services try to make incompatible changes to the same database. Or what happens when two different users try to make incompatible changes to the same Google Doc? Or what happens when you try to GIT Merge a commit that has incompatible changes? It’s your code, so it’s in your control what happens, and also in your control how to react to what you can’t control. Y…

All of these cases have a well-defined conflict resolution mechanism. All of these cases except for Google Docs explicitly have a way for the client to be notified that their requested change failed (I believe Google Docs just defines the editing operations such that a conflict can always be automatically resolved).

The DOM API does not have any way to even notify the client that their DOM manipulation failed.

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

#43

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.

Like QML from Qt?

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

#44
post #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...

Assumption is a mother of all fuc$ups...

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

#47
post #13
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 could see this being used in a "pre-fetch" manner for single-page applications. For example, preparing and rendering the next page or component before the user has opened it. So when the user does click to open the next page or component, it can be displayed immediately. The ability to perform that rendering in the background without blocking the main thread would offer some real value.

But this will consume CPU and RAM and will make the page user is browsing work slower. Especially for users with low-end hardware.

If you use server-side rendering (for example, if you use PHP on your server) then you won't need all of this and pages will load instantly without any complicated preloading.

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

#48

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.

We used to firmly believe in what you said too. However, we've seen advantages to the open web:

1. You're not beholden to the app stores' whims.

2. It literally is "write once, run everywhere"

3. Webassembly & WebGPU add performance & language independence

For most cases, the web is a viable, nay superior alternative.

For cases with special sensor access & ultra high speed (rich games, Video encoding) native apps are the only way.

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

#49
post #33

Earlier quoted context omitted.

There's a lot of tricks you can try, but even rendering the first set of visible rows can take more than a 60fps time window will allow.

Don't pick a fixed value for the batch size; render until your time is exhausted and then wait for the next batch. Yes, this'll be slower overall, but you ensure that the app stays responsive regardless of device or CPU availability.

Are you recommending an app imposed rendering timer (say 15ms) or is there an in built API for Opportunistic scheduling of Dom updates?

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

#50

I don't like this. It must be slow and bloated because it is a DOM written in JS rather than native optimized DOM implementation. And why would anyone need that?

Correct me if I'm wrong, but if you work with DOM, modify/read properties, they lead to DOM trashing and re-rendering. If you do this 100 times per event handler, it will become slow.

If you do all that work in a worker and then only update the real DOM once, it will be much faster.

Render/paint is the slowest part in a JS application.

Post reply on HN