jQuery 1.7's on() vs jQuery 1.6.4's delegate() (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="http://code.jquery.com/jquery-1.6.4.min.js">
</script>
<script>
  $16 = jQuery.noConflict();
</script>
<script src="http://code.jquery.com/jquery-1.7.min.js">
</script>
<script>
  $17 = jQuery.noConflict();
</script>
<div id="container16">
</div>
<div id="container17">
</div>
<script>
  window.i = 0;
  window.toAppend = '<a class="delegateMe"></a> ';
  $16(function() {
    window.$container16 = $16('#container16');
    for (window.i = 0; i < 100; i++) {
      $container16.append(window.toAppend);
    }
  });

  $17(function() {
    window.$container17 = $17('#container17');
    for (window.i = 0; i < 100; i++) {
      $container17.append(window.toAppend);
    }
  });
</script>

Teardown


    $container16.undelegate('click', 'a.delegateMe');
    $container17.off('click', 'a.delegateMe');
  

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery 1.6.4's delegate()
$container16.delegate('click', 'a.delegateMe', function() {
  console.log('hello world');
});
ready
jQuery 1.7's on()
$(document).on('click', 'a.delegateMe', function() {
  console.log('hello world');
});
ready

Revisions

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