jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase .
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2 Can be accessed at:
https://jsperf.app/negative-modulo/2 Event listeners comparison - $().click, addEventListener, onclick (v28) Revision 28 of this benchmark created on March 3, 2024 Preparation HTML <script src ="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" > </script >
<div > Test</div > <div > Test</div > <div > Test</div > <div > Test</div >
Setup divs = document .getElementsByTagName ('div' );
length = divs.length ;
for (var i = 0 ; i < length; i++){
$(divs[i]).unbind ().prop ("onclick" , null );
}
Teardown for (var i = 0 ; i < length; i++){
document .addEventListener ('click' , 'div' , function ( ){
console .log ('hi' );
});
}
Test runner Ready to run.
Run Quick Run Testing in Test Ops/sec $().click anon for (var i = 0 ; i < length; i++){
$(divs[i]).click (function ( ){
console .log ('hi' );
});
}
ready
addEventListener anon for (var i = 0 ; i < length; i++){
divs[i].addEventListener ('click' , function ( ){
console .log ('hi' );
});
}
ready
onclick anon for (var i = 0 ; i < length; i++){
divs[i].onclick = function ( ){
console .log ('hi' );
};
}
ready
$().click var f = function ( ){
console .log ('hi' );
}
for (var i = 0 ; i < length; i++){
$(divs[i]).click (f);
}
ready
addEventListener var f = function ( ){
console .log ('hi' );
}
for (var i = 0 ; i < length; i++){
divs[i].addEventListener ('click' , f);
}
ready
onclick var f = function ( ){
console .log ('hi' );
}
for (var i = 0 ; i < length; i++){
divs[i].onclick = f;
}
ready
Revisions You can edit these tests or add more tests to this page by appending /edit to the URL.
Revision 1 : published on October 14, 2010 Revision 2 : published on October 14, 2010 Revision 4 : published on November 15, 2012 Revision 5 : published on November 15, 2012 Revision 6 : published on November 15, 2012 Revision 7 : published on November 15, 2012 Revision 8 : published on November 15, 2012 Revision 9 : published on January 21, 2013 Revision 10 : published on August 20, 2013 Revision 11 : published by LZAntal on November 23, 2013 Revision 12 : published on December 20, 2013 Revision 13 : published on December 25, 2013 Revision 15 : published on February 4, 2014 Revision 16 : published on April 28, 2014 Revision 17 : published by rvmn on July 23, 2014 Revision 22 : published on March 26, 2015 Revision 28 : published on March 3, 2024