by mraleph · 13y ago · 0 comments
One of the most important things to remember while using jsPerf is that setup phase can and will be executed multiple times. As the result the list of listeners attached to the DOM node is growing and this in turn slows down the event dispatch.
"No return" case is run second so the list of listeners is already large and thus it is slower than "return case".
You should either unregister listeners in tear down phase or register them only once at global initialization time. Here is the fixed variant:
http://jsperf.com/always-return-on-jquery-events/28
[also from the JavaScript VM point of view function () { } and function () { return; } are completely the same]
If the OP wanted to measure function with or without return , even without realizing how futile that is, they still should not include things like jQuery.
And the web being as it is, testing with jQuery might even be more useful than testing without it.
You should read http://zedshaw.com/essays/programmer_stats.html
What I meant was that if I'm going to run a website with jQuery calls, I should absolutely test with jQuery calls. It makes no sense to claim that one should, say, always use short variable names, if one then ships with google closure.