jQuery body vs. document.body selector (v29)

Revision 29 of this benchmark created by Koen Vendrik on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://37.128.149.176/staging/browserkit/browserkit-1.2.0.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
$('body') : Browserkit
var $body = B('body'),
    $section = B('#content')[0],
    str = "How now brown cow",
    i = 100;

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

Revisions

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