Suppose I have an element matching ".foo".
<div class="foo"></div>
I've learned from experience the performance hit from calling finders more than once, as in, if I'm trying to change the same object several times.
$(".foo").doOneThing();
$(".foo").doAnotherThing();
$(".foo").doSomethingElse();
// Makes jQuery look for ".foo" three times, bad!
versus
$foo = $(".foo");
$foo.callAllThreeOfTheThingMethodsInThePreviousBlock();
// Calls $(".foo") only once, but occupies memory with a jQuery object version of the foo div.
My question is, how many times would you have to use this finder before setting aside memory to hold the jQuery object instead of making the jQuery method call again?
I ask since the other day I had made every finder I called more than once into a stored $object variable; my boss had said to instead use the finder rather than a stored object if I was only using the finder, say, two or three times. What's your take on this?