top | item 21685722

(no title)

Devagamster | 6 years ago

Not really. The assumption is that modifying the dom directly is the expensive part.

discuss

order

erikpukinskis|6 years ago

Doesn’t seem like a good bet for the long term. There’s no practical reason why modifying the DOM couldn’t be practically free. Especially if we can hint to the layout engine that we’re working in a well behaved subset. (Or the layout engine can detect such)

Manishearth|6 years ago

Hi, I work on a browser, layout and styling are expensive.

Browsers already to tons of work to avoid recomputing too much of this stuff whenever the DOM changes, and it's still inadvisable to poke the DOM too much. I don't see this changing anytime soon. There are various new features that allow for some level of hinting, but it's not going to obviate this. Browsers need to have incremental layout/styling prepare for any kind of potential change, whereas if you have a reactive UI framework you know what kinds of changes can happen, and can optimize diffing based on that.

There's a reason why a lot of JS UI frameworks use a virtual DOM. It sounds expensive to maintain, but directly operating on the DOM is more expensive.

aassddffasdf|6 years ago

Right. All this treating the DOM with kid gloves seems to be due to its pre-existing weaknesses. Why not just fix those?

outworlder|6 years ago

> There’s no practical reason why modifying the DOM couldn’t be practically free.

Oh yeah, modifying the DOM is practically free. Which is why React and the like do that in their mirror DOM.

Actually applying the resulting changes, on the other hand...