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

JavaScript performance comparison

Revision 12 of this test case created

Info

The Difference Between jQuery’s .bind(), .live(), and .delegate()

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  function handler() {
    $('p').text("CLICK !");
  }
</script>
<div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div><div>verylongcontents</div>
<div id="context">
<p>Event test</p>
</div>
 

Preparation code output

verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents
verylongcontents

Event test

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
.on
$(document).on('click', 'p', handler);
pending…
.on() in context
$('#context').on('click', 'p', handler);
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