jQuery body vs document Events (v46)

Revision 46 of this benchmark created by Colin McLeod on


Description

Quick test to check whether using native document object vs 'body' is faster.

Preparation HTML

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

<div id="context">
<p>Some paragraph</p>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Body delegate
$('body').delegate('p','click',$.noop);
ready
Body On
$('body').on('click','p', $.noop);
ready
Document Delegate
$(document).delegate('p','click',$.noop);
ready
Document On
$(document).on('click','p',$.noop);
ready

Revisions

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