Improved jQuery selector performance tips

It's important to make sure your optimise your jQuery selectors to improve performance. This is especially important on sites that make heavy use of jQuery.

1) Select with Efficiency:

$('#id') – the fastest method $('tag.classname') – next fastest: this grabs all matching tags FIRST, then iterates through them to find the matching classes $('.classname') – the slowest: it has to iterate through ALL DOM ELEMENTS on the page

2) Cache to Avoid Reselection

Interacting with the DOM as little as possible will drastically speed up your applications.