question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Walking through the DOM is slow

See original GitHub issue

You state that walking through the DOM isn’t slow, but in reality it really is. Accessing things like firstNode or childNodes is vastly slower than storing a light-weight representation of it (aka virtual DOM).

Furthermore, handling of keyed nodes becomes problematic when using DOM nodes. There simply isn’t any performant way of doing this when using the DOM as the source-of-truth.

Have you see this too? http://vdom-benchmark.github.io/vdom-benchmark/

Furthermore, you shouldn’t really be comparing yourself to the virtual-dom library and stating that library as the de-facto virtual DOM standard, it’s one of the slowest implementations of virtual DOM out there in Safari (it’s noticeably faster than morphdom in Chrome according to your own benchmark).

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
snewcomercommented, Mar 12, 2020

For context, this library is at the core of Phoenix Live View (LiveWire for Laravel). Total diff is much smaller than equivalent SPA apps since users server side render their page and sprinkle in small reactive parts into page. This makes this library a perfect candidate since v-dom only wins once I/O is swamped (due to large changes). Otherwise real DOM is better/on par with v-dom.

https://github.com/phoenixframework/phoenix_live_view

1reaction
Bobriscommented, Mar 8, 2020

Not much changed. Real DOM complexity slowness is inherent in its design, so it cannot be really faster. trueadm now works on React. But React raw speed in 5 years improved only very slightly, it is not goal really. Worst IE you need to support is IE11, much better than IE8 or IE9, but still crap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do developers think the DOM is slow? : r/javascript - Reddit
It is probably a bit of misconception here. The DOM itself is not slow, however when you make changes that triggers re-painting of...
Read more >
The “Live DOM” Is Not “Slow”, “Bad”, Or “Wrong”. Web ...
Yes innerHTML is around 30 times slower than working directly on the DOM, that's one of MANY reasons why you shouldn't be using...
Read more >
Why is the DOM slow? | Hacker News
The short answer is that the DOM is not slow. Adding & removing a DOM node is a few pointer swaps, not much...
Read more >
Most efficient way to iterate over all DOM elements
Basically, just set some minimum possible size of an element you're looking for, and scan the entire area that your new fixed position...
Read more >
Direct DOM manipulations are expensive. | by Abhijit Hycinth
Phew, now that we've walked through the basic flow of rendering in a ... and is one of the main causes of slow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found