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

Revision 30 of this benchmark created by tyareg on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
</script>
<div id="context">
  <p>
    Some paragraph
  </p>
  <p id="element">
    Some ID'd paragraph
  </p>
</div>

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
.delegate() on context using ID
$('#context').delegate('#element', 'click', $.noop);
ready
.delegate() on document using ID
$(document).delegate('#element', 'click', $.noop);
ready
.on() on context using ID
$('#context').on('click', '#element', $.noop);
ready
.on() on document using ID
$(document).on('click', '#element', $.noop);
ready
click()
$('#element').on('click', $.noop);
ready
click
$('#element').click($.noop);
ready

Revisions

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