jQuery body vs. document.body selector (v53)

Revision 53 of this benchmark created 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 = 100;

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

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

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 = 100;

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

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

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.