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

Revision 10 of this benchmark created on


Preparation HTML

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

<div id="context">
<div><div><div><div><div><div><div><div>
<div class='nest'><p>Some paragraph</p></div>
<p>Some paragraph</p>
<p>Some paragraph</p>
<p>Some paragraph</p>
<div class='nest'><p>Some paragraph</p></div>
<p>Some paragraph</p>
<p>Some paragraph</p>
<p>Some paragraph</p>
<p>Some paragraph</p>
</div></div></div></div></div></div></div></div>
</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()
$(document).find('.nest').on('click', 'p', $.noop);
ready
.on() on document
$(document).on('click', 'p', $.noop);
ready
document .nest p
$(document).on('click', '.nest> p', $.noop);
ready
#context .nest p
$('#context').on('click', '.nest> p', $.noop);
ready
.nest p
$('.nest').on('click', 'p', $.noop);
ready
document #context .nest p
$(document).on('click', '#context .nest> p', $.noop);
ready

Revisions

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