Caching in jQuery

What is great about jQuery is its simplicity in selecting elements. We all use it here and there, basically everywhere. This simplicity comes with its drawbacks. jQuery traverses through all elements every time we use selectors. So to boost up your jQuery application you should always cache your selections to some variable (if you find yourself using the same selection more than once). In case you are not selecting an element more than once you should not cache your selection by assigning it to some variable.

Here is an example:
var cached = $('.someElement'); 
Here are the performance tests:
for (i = 0; i < 1000; i++) { 
    $('.the').text(i + ' '); 
// ~260ms 

var the = $('.the'); 
for (i = 0; i < 1000; i++) { 
    the.text(i + ' '); 
// ~30ms

As you can see caching increased performance by nearly 10 times.