2 ms·
I call linkbait/trollbait. > People often throw around the statement “The DOM is slow”. This is a completely false statement. Utterly stupid. Look: http://jsfi
by mathias 14y ago
I call linkbait/trollbait.
> People often throw around the statement “The DOM is slow”. This is a completely false statement. Utterly stupid. Look: http://jsfiddle.net/YNxEK/ http://jsfiddle.net/YNxEK/. Ten THOUSAND divs in about 200 milliseconds.
How is that even an argument? Just because you can insert a fragment containing 10k <div>s in 200 milliseconds doesn’t mean that the DOM is not slow compared to other operations in JavaScript.
DOM operations are still the slowest operations you can perform using JavaScript in a web browser.
- niggler 14y ago"DOM operations are still the slowest operations you can perform using JavaScript in a web browser." You aren't refuting the author's point. "The DOM is slow" is based on an absolute timing. No one is making a relative comparison. In general its possible to argue that operation X is fast, even if X is the slowest of a set of operations, if you take an absolute perspective.
- mathias 14y agoThe reason people say “the DOM is slow” is because it’s slower than anything else in JavaScript, not because of an absolute measurement. If you’re calling JavaScript features slow or fast based on absolute measurements, you’re doing it wrong. Read up on JavaScript benchmarking. Create and run some jsPerf tests on various devices and browsers, and compare the results. You’ll quickly find that absolute numbers are meaningless in this case.