Does jQuery do any kind of caching of “selectors”?

Always cache your selections!

It is wasteful to constantly call $( selector ) over and over again with the same selector.

Or almost always… You should generally keep a cached copy of the jQuery object in a local variable, unless you expect it to have changed or you only need it once.

var element = $("#someid");

element.click( function() {

  // no need to re-select #someid since we cached it
  element.hide(); 
});

Leave a Comment