Performance of jQuery selectors vs local variables

Reusing the selector reference, your first case, is definitely faster. Here’s a test I made as proof:

http://jsperf.com/caching-jquery-selectors

The latter case, redefining your selectors, is reported as ~35% slower.

Leave a Comment