referencing tag#id vs. just #id in jQuery

Eli Cochran eli at
Fri Jan 11 22:21:05 UTC 2008

Debugging in the Reorder, I noticed that the container reference is  

I just read a comment in the jQuery forum which says that, as of last  
July, referencing just the id with out the tag reference is  
significantly faster eg. jQuery('#foo') not jQuery('div#foo') . The  
commenter said that when you reference an id with the tag reference  
jQuery ends up looping through every element to check for the id  
instead of using getElementById.

This might have been something that was improved in subsequent  
versions of jQuery. I'll try to find out.

- Eli
. . . . . . . . . . .  .  .   .    .      .         .              .     

Eli Cochran
user interaction developer
ETS, UC Berkeley

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the fluid-work mailing list