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

JavaScript performance comparison

Revision 38 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js">
</script>
<div id="contesto">
  <p>
    test sugli eventi
  </p>
</div>

Preparation code output

test sugli eventi

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() con Contesto
$('p', $('#contesto')).live('click', $.noop);
pending…
.delegate()
$('#contesto').delegate('p', 'click', $.noop);
pending…
.delegate() nel Documento
$(document).delegate('p', 'click', $.noop);
pending…
.on()
$('#contesto').on('click', 'p', $.noop);
pending…
.on() nel Documento
$(document).on('click', 'p', $.noop);
pending…
.click()
$('p').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