Smaller scope, yet slower performance in jQuery?

I’ve created a jsfiddle here: http://jsfiddle.net/2tfbs/1/

Since the scope for ‘find’ is smaller in the bottom loop, why is the speed so much slower? If you change the jQuery versions there’s a performance hit (a massive one in Firefox 5) going from 1.4.4 and onward but in all versions the conclusion is basically the same.

If you change the first loop to simply $ (‘#container’) and not a cached variable, the result is also the same and seemingly contradicts everything I’ve read that says “caching is faster”.

Am I doing something wrong? I don’t understand what’s going on.

newest questions tagged jquery – Stack Overflow

About Admin