innerHTML vs removeChild vs jquery.remove (v71)

Revision 71 of this benchmark created on


Description

what method for empty a element is faster ?

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id='box'></div>

Setup

var box = document.getElementById('box');
    box.innerHTML = '<div id="inner">hello</div>';
    var inner = box.firstChild;

Test runner

Ready to run.

Testing in
TestOps/sec
removeChild
if (box.firstChild) { box.removeChild(box.firstChild); }
ready
innerHTML
if (box.firstChild) { box.innerHTML = ''; }
ready
jQuery.remove
if (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.