Are there any significant performance differences these two blocks of code?
var element = $("#some-element");
SomeMethod1(element);
SomeMethod2(element);
SomeMethod3(element);
and…
SomeMethod1($("#some-element"));
SomeMethod2($("#some-element"));
SomeMethod3($("#some-element"));
That depends on what you mean by
significant.The first code snippet will always be faster than the second, because calling
$()more than once has a cost (as jQuery does not cache the results of previous calls). Whether it’s significant or not depends on your performance requirements.