jQuery body vs. document.body selector (v30)

Revision 30 of this benchmark created by devu 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
document.getElementById
var $section = document.getElementById('content'),
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.