$().click vs addEventListener (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

$('<div id="test"></div>').appendTo(document.body);

Teardown


    $('#test').remove();
  

Test runner

Ready to run.

Testing in
TestOps/sec
$().click
$('#test').click(function(){
  console.log('hi');
});
ready
addEventListener
document.getElementById('test').addEventListener('click', function(){
  console.log('hi');
});
ready
addEventListener 2
var testElem = document.getElementById('test');
testElem.addEventListener('click', function() {
  console.log('hi');
}, false);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.