jQuery body on vs document on (v6)

Revision 6 of this benchmark created by Igor Polyakov on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul id="myList">
</ul>

<script>
  var listArray = [],
      tpl = '<a href="%i">%i</a>',
      tplFn = function(value) {
    return tpl.replace(/%i/g, value);
      },
      i;
  
  // loop and create 1000 entries
  for (i = 0; i <= 1000; i++) {
   listArray.push(tFpln(i));
  }
  
  
  $('#myList').append(listArray.join(''));
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Delegate with Id
$('#myList').on('click', 'a', $.noop);
ready
Delegate with document
$(document).on('click', 'a',  $.noop);
ready
Delegate with document.body
$(document.body).on('click', 'a', $.noop);
ready
Delegate with jQuery body
$('body').delegate('click', 'a', $.noop);
ready

Revisions

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