jQuery body vs. document.body selector (v31)

Revision 31 of this benchmark created on


Description

If you testing selectors test how selectors perform not how innerHTML perform for already selected node. ;)

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'),
  str = "How now brown cow",
  i = 100;

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

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

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

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

while (i--) {
  B('#content')[0].innerHTML = str;
}
ready
document.getElementById
var str = "How now brown cow",
  i = 100;

while (i--) {
  document.getElementById('content').innerHTML = str;
}
ready

Revisions

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