jQuery on vs addEventListener (v10)

Revision 10 of this benchmark created on


Preparation HTML

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

Setup

$.id = function(id){return $(document.getElementById(id));};
    function targetFunc () { void(0) };
    var elem = document.getElementById('target');

Test runner

Ready to run.

Testing in
TestOps/sec
Inefficient jQuery solution
$('#target').on('click',targetFunc);
 
ready
Slightly improved jQuery solution
$.id('target').on('click',targetFunc);
 
ready
Native solution
elem.addEventListener('click',targetFunc,false);
ready
Non-addEventListener
elem.onclick = targetFunc;
ready

Revisions

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