4 ms·
Here's a version that's not Chrome-only: http://jsfiddle.net/eymAS/21/ http://jsfiddle.net/eymAS/21/ I've been wondering why I keep hearing that the DOM is sup
by fhd2 13y ago
Here's a version that's not Chrome-only:
http://jsfiddle.net/eymAS/21/ http://jsfiddle.net/eymAS/21/
I've been wondering why I keep hearing that the DOM is supposed to be slow. Don't people mean to say that rendering (i.e. mostly CSS) is slow? This fiddle is certainly not doing much with the DOM except setting style attributes.
- just2n 13y agoPeople generally mean their manipulation of DOM is effectively slow. That's a perfectly accurate statement, but the problem is calling the DOM slow as a result. The real culprit is often that doing stupid things with the DOM cause style recalcs, reflows, layouts, compositing, painting, etc. Those are all comparatively expensive.
- vladmoz 13y agoThe problem with the DOM is not that it's intrinsically slow, but that it's very easy to do slow things with it inadvertently. There are often N different ways to do things, due to the evolution of HTML. The newer approaches tend to be designed with things like GPU acceleration in mind (e.g. CSS transforms), whereas older methods often had lots of heavy interactions and computations because they weren't expected to be used dynamically. Just like optimizing any software takes skill and knowledge, so too does writing HTML, whether dynamic or not. Tools for understanding what's going on with the DOM and with dynamic HTML are slowly becoming available as well, which will help with this.