innerHTML vs removeChild (v322)

Revision 322 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
removeChildFirst
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
ready
innerHTML
box.innerHTML = '';
ready
removeChildLast
while (box.lastChild) {
  box.removeChild(box.lastChild);
}
ready
innerHTMLNull
box.innerHTML = null;
ready

Revisions

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