jQuery .live() vs .delegate() vs .on() (v56)

Revision 56 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<div id="context">
  <p>
    Some paragraph
  </p>
</div>

Setup

var el = document.getElementsByTagName('p')[0];

Teardown


    $('p').die('click');
    $('#context').undelegate('p', 'click', $.noop);
    $(document).undelegate('p', 'click', $.noop);
    $('#context').off('click', 'p', $.noop);
    $(document).off('click', 'p', $.noop);
    $("p").off("click", $.noop);
    $("p").unbind('click');
  

Test runner

Ready to run.

Testing in
TestOps/sec
.live()
$('p').live('click', $.noop);
ready
.live() with context
$('p', $('#context')).live('click', $.noop);
ready
.delegate()
$('#context').delegate('p', 'click', $.noop);
ready
.delegate() on document
$(document).delegate('p', 'click', $.noop);
ready
.on()
$('#context').on('click', 'p', $.noop);
ready
.on() on document
$(document).on('click', 'p', $.noop);
ready
.on() direct
$("p").on("click", $.noop);
ready
.click()
$("p").click($.noop);
ready
.bind()
$("p").bind('click', $.noop);
ready
native click
el.addEventListener('click', function() {
  $.noop
});
ready

Revisions

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