Empty an element (v11)

Revision 11 of this benchmark created on


Preparation HTML

<div id="myroot">
  <span>
    blah
  </span>
  <ul>
    <li>
      hihi
    </li>
    <li>
      this is stupid
    </li>
  </ul>
  <img src="https://www.google.com/logos/2012/ada_lovelaces_197th_birthday-991005-hp.jpg"
  />
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Empty one by one
var el = document.getElementById("myroot");
while (el.firstChild) {
  el.removeChild(el.firstChild);
}
ready
Empty innerHTML
var el = document.getElementById("myroot");
el.innerHTML = "";
ready
Empty innerText
var el = document.getElementById("myroot");
el.textContent = "";
ready

Revisions

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