jQuery .on() vs .click() vs .delegate()

JavaScript performance comparison

Revision 68 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<table>
    <tr>
        <td>td1</td>
        <td>td2</td>
        <td>td3</td>
    </tr>
</table>

Preparation code output

td1 td2 td3

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()
$('td').on('click', function() {
  alert('on');
})
pending…
.click()
$('td').click(function() {
  alert('click');
});
pending…
.on() on table
$('table').on('click', 'td', function() {
  alert('on');
});
pending…
.delegate() on table
$('table').delegate('td', 'click', function() {
  alert('delegate');
});
pending…
.on() on document
$('document').on('click', 'td', function() {
  alert('on');
});
pending…
.delegate() on document
$('document').delegate('td', 'click', function() {
  alert('delegate');
});
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