2 ms·
From another POV, browsers are pretty bad at displaying HTML and CSS. The layout mechanics are complicated. DOM is slow and non-transactional which means jumpy
by nine_k 5y ago
From another POV, browsers are pretty bad at displaying HTML and CSS.
The layout mechanics are complicated. DOM is slow and non-transactional which means jumpy redraws and jank during partial updates, and you just can't render it at 60 fps, or even 30 fps, like you would with a direct-mode game-style UI; at best you can peg several CPU cores to 100%.
And this can never be fixed because backwards compatibility. It can only be replaced in some indefinite future.
This is why the virtual DOM was invented. And yes, if you know how to cook it, it's faster than jQuery.
OTOH great many web pages are not apps, and should not be treated as SPAs. But this happens, and it will until server-side rendering is made ridiculously easy to set up, and also becomes the fashion.
- polyrand 5y agoYes! Thanks for the insight about the virtual DOM. I'm definitely not saying the virtual DOM is bad, or that JS is bad. But like you said, people are starting to mix pages and apps, thus also mixing the complexity requirements of each one. Luckily, it seems server-side rendering is coming back, even in React.
- naasking 5y agoThe fastest DOM update libraries in the benchmarks I've seen eschew the vDOM entirely. See domdiff for instance.
- nine_k 5y agoOne may not need to build an entire tree and then compare to another tree; the generation and comparison may go hand in hand to avoid building an actual vDOM. It's DOM diffing anyway. It's still the "track and update dirty regions" logic of 8-bit game consoles, instead of the "redraw the whole screen from scratch" logic of modern game engines. DOM is not performant enough, and likely will never be, in its current shape. Merging the vDOM-less transactional DOM update logic into the DOM standard could be nice, though.