In fact, there is no real difference between the two ways to select an item (other than reading). I created a new jsperf test case that more objectively evaluates the case:
-> http://jsperf.com/jquery-selector-performance-20130730
Why is your test result so strange? Your test case is more likely to be inaccurate than any real performance difference between both tests.
You can go and COMPLETE the test order of your initial test: first check the code $(((('#lol')))) and then $('#lol') . I am absolutely sure that you will get the exact opposite result from your current test; -)
I am not an expert in this, but on the one hand, browsers are very smart today and will cache javascript code / variables. Also jQuery might save the value after the first call.
Philipp
source share