|
|
|
|
|
by mraleph
4634 days ago
|
|
Answer is simple: you are adding more and more listeners as jsPerf runs your test case. 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] |
|