I need a bit of clarification on jQuery caching. To my understanding, this:
var $element = $('#element');
gives us benefit if we will refer to this element more than once (by refer I mean change it, or listen for an event on it.). Is this correct?
If it is correct, does the following code make any sense, or not, and why?
var $button = $('#submit, #save, #reset');
What I see is that jQuery allows me to do this (hence applying the same nice theme to all 3 buttons), but I cannot find docs anywhere does this help performance in any way.
Yes it makes sense, but only if you have to do something more than once with those buttons as a set. It’s not probable.
I suggest you don’t make too much effort with jquery optimization until you really do things at high frequency (like animations).