jQuery body vs. document.body selector (v24)

Revision 24 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
JS
var d = document;
var db = d.body;
var section = d.getElementById('content');
var str = "How now brown cow"
var 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.