nextSibling vs childNodes increment

Benchmark created on


Preparation HTML

<script>
  var children1 = document.body.children,
      children2 = document.body.childNodes,
      firstChild = document.body.firstChild,
      firstElChild = document.body.firstElementChild,
      next = "nextSibling";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
nextSibling
var child = firstChild;
while ((child = child[next])) {
 //do stuff
}
ready
nextSibling 2
var child = firstChild;
while ((child = child.nextSibling)) {
 //do stuff
}
ready
nextElementSibling
var child = firstElChild;
while ((child = child.nextElementSibling)) {
 //do stuff
}
ready
childNodes increment
var i = 0,
    child = firstChild;
while ((child = children1[++i])) {
 //do stuff
}
ready
children increment
var i = 0,
    child = firstChild;
while ((child = children2[++i])) {
 //do stuff
}
ready

Revisions

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