body vs document (v14)

Revision 14 of this benchmark created by Adam Becker on


Description

Which is quicker with jQuery? Binding to document or an element directly ?

Preparation HTML

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

Setup

$("<a class='foo'>Hi</a>").appendTo('body')

Test runner

Ready to run.

Testing in
TestOps/sec
document
$(document).on('click', '.foo', function() {



});

$('.foo').click()
ready
element
$('body').on('click', '.foo', function() {



})

$('.foo').click()
ready

Revisions

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