jQuery on vs addEventListener (v12)

Revision 12 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) };

Test runner

Ready to run.

Testing in
TestOps/sec
Inefficient jQuery solution
$('#target').on('click',targetFunc);
$('#target').off('click',targetFunc);
ready
Slightly improved jQuery solution
$.id('target').on('click',targetFunc);
$.id('target').off('click',targetFunc);
ready
Native solution
document.getElementById('target').addEventListener('click',targetFunc,false);
document.getElementById('target').removeEventListener('click',targetFunc,false);
ready

Revisions

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