Possible Duplicate:
What is the cost of '$(this)'?
I constantly see in some developers code where $(this) may exist 3-5 times referring to the same dom node. I’m wondering at what point this is worth optimizing and storing in a variable like var el = $(this); ?
Does anyone know of a good reliable source for documentation on the performance of this?
If you have to use it more than once, cache it. IMHO, why keep calling the DOM for something?
Note: I recommend adding a
$before the variables that are actually jquery DOM elements. It makes it easier to keep track of what the variable really is.