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

JavaScript performance comparison

Revision 5 of this test case created by Andrew Smith

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="context" style="height:200px; overflow: scroll;">
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
  <p>
    Some paragraph
  </p>
</div>

Preparation code output

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Some paragraph

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
.live()
$('p').live('click', $.noop);
pending…
.live() with context
$('p', '#context').live('click', $.noop);
pending…
.delegate()
$('#context').delegate('p', 'click', $.noop);
pending…
.delegate() on document
$(document).delegate('p', 'click', $.noop);
pending…
.on()
$('#context').on('click', 'p', $.noop);
pending…
.on() on document
$(document).on('click', 'p', $.noop);
pending…
.bind()
$('p').bind('click', $.noop);
pending…
.bind() with context
$('p', '#context').bind('click', $.noop);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment