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

Revision 68 of this benchmark created on


Preparation HTML

<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>

Test runner

Ready to run.

Testing in
TestOps/sec
.on()
$('td').on('click', function() {
  alert('on');
})
ready
.click()
$('td').click(function() {
  alert('click');
});
ready
.on() on table
$('table').on('click', 'td', function() {
  alert('on');
});
ready
.delegate() on table
$('table').delegate('td', 'click', function() {
  alert('delegate');
});
ready
.on() on document
$('document').on('click', 'td', function() {
  alert('on');
});
ready
.delegate() on document
$('document').delegate('td', 'click', function() {
  alert('delegate');
});
ready

Revisions

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