innerHTML vs removeChild (v252)

Revision 252 of this benchmark created on


Description

what method for empty a element is faster ?

Preparation HTML

<div id='box'></div>

Setup

var box = document.getElementById('box');
    box.innerHTML = 'sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>'

Teardown


    box.innerHTML = 'sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df<p>df gsdfg sf g<b>'
  

Test runner

Ready to run.

Testing in
TestOps/sec
removeChild
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
ready
.remove with lastChild
while (box.lastChild) {
  box.lastChild.remove();
}
ready
.remove
while (box.firstChild) {
  box.firstChild.remove();
}
ready

Revisions

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