News for hackers. Stuff that matters.
Re:The DOM isn't slow by iwillreply on Tuesday March 19, 2013 @10:32AM (#5401078)
It's strange you blame jQuery outright for slowness of the DOM, and reference the jsFiddle as your reference point of speed.

Writing this utilising jQuery for DOM manipulation ( http://jsfiddle.net/YNxEK/7/ ) is getting me consistently faster results than the original fiddle ( http://jsfiddle.net/YNxEK/ ) on Firefox and Chrome.

Re:The DOM isn't slow by mikepurvis on Tuesday March 19, 2013 @10:55AM (#5401230)
Interesting. On a whim, I tried changing your fiddle to use Array.join construction rather than string appends, but string appends remain 5-10% faster:

http://jsfiddle.net/2kWdC/

That way uses an indexed for-loop, but the while loop with Array.push was just as bad.

Re:The DOM isn't slow by iwillreply on Tuesday March 19, 2013 @11:12AM (#5401343)
Interesting, I very briefly deliberated while vs for, and how the performance of both had changed since last look.

But checking at: https://blogs.oracle.com/greimer/resource/loop-test.html

Still seemed to demonstrate a decreasing while loop as the fastest in my test.

Re:The DOM isn't slow by Guillaume86 on Tuesday March 19, 2013 @10:47AM (#5401181)
You just use innerHTML with a big string, it's not the equivalent of the original fiddle and it's not a fair comparison.
Re:The DOM isn't slow by latviancoder on Tuesday March 19, 2013 @10:50AM (#5401197)
Here is a comparison, that looks more fair to me:

http://jsfiddle.net/d5geB/

Re:The DOM isn't slow by masklinn on Tuesday March 19, 2013 @11:08AM (#5401317)
Why not? The original fiddle uses a documentFragment and does a bulk-insert of that in the document itself.
Re:The DOM isn't slow by emehrkay on Tuesday March 19, 2013 @10:49AM (#5401193)
Dude, you aren't creating dom nodes.

Here is the equivalent:

http://jsfiddle.net/EmEhRKay/YNxEK/10/

Re:The DOM isn't slow by iwillreply on Tuesday March 19, 2013 @11:03AM (#5401282)
Why would you append on every loop. Rather than build the string and then append the whole lot on one block?

If you compare the DOM of the original fiddle and the DOM of following the fiddle I posted. You will see they are the same.

I'm not saying what I referenced is the 'best' way of doing things. But that the debate in the original article (based on the provided examples) is pretty null.

Re:The DOM isn't slow by emehrkay on Tuesday March 19, 2013 @11:28AM (#5401432)
You're right, my example was different. But upon fixing it to match the original article's example, but with jQuery creating the dom nodes, it is still slower

http://jsfiddle.net/EmEhRKay/YNxEK/13/