jQuery body vs. document.body selector (v36)

Revision 36 of this benchmark created by Kurt on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<section id="content">
</section>

Test runner

Ready to run.

Testing in
TestOps/sec
$('body')
var $body = $('body'),
    $section = $body.find('#content'),
    str = "How now brown cow",
    i = 1000;

while (i--) {
 $section.html(str);
}
ready
$(document.body)
var $body = $(document.body),
    $section = $body.find('#content'),
    str = "How now brown cow",
    i = 1000;

while (i--) {
 $section.html(str);
}
ready
$('body') : not cached
var $body = $('body'),
    $section = $('body').find('#content'),
    str = "How now brown cow",
    i = 1000;

while (i--) {
 $section.html(str);
}
ready
$(document.body) : not cached
var $body = $(document.body),
    $section = $(document.body).find('#content'),
    str = "How now brown cow",
    i = 1000;

while (i--) {
 $section.html(str);
}
ready

Revisions

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