removeChildren

Benchmark created by Nikita Vasilyev on


Description

From http://elv1s.ru/files/html+css/removeChildren.html

Note: This test is incorrect. After the first test empties element, it is not restored again, so obviously all tests after that will be über fast. See revision 3 for a fair version of this test.

Preparation HTML

<script>
  var element = window.element = document.createElement("div");
  var i = 2000;
  while (i--) {
   var p = document.createElement("p")
   var j = 5;
   while (j--) {
    var span = document.createElement("span")
    span.appendChild(document.createTextNode(i * j + "yada-yada"))
    p.appendChild(span)
   }
   element.appendChild(p)
  }
  document.body.appendChild(element)
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
element.innerHTML = ""
ready
textContent
element.textContent = ""
ready
removeFirstChild
var child
while (child = element.firstChild) {
 element.removeChild(child)
}
ready

Revisions

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

  • Revision 1: published by Nikita Vasilyev on
  • Revision 2: published by Thomas Aylott on
  • Revision 3: published by Mathias Bynens on
  • Revision 7: published on
  • Revision 8: published by Francis Avila on
  • Revision 9: published on