Remove v.s. Detach vs hide vs empty vs "" (v40)

Revision 40 of this benchmark created on


Preparation HTML

<script src="https://code.jquery.com/jquery-git2.min.js"></script>

<div id="html"></div>

Setup

var $inner = '<div id="sup"></div><div id="sup"></div><div id="sup"></div><div id="sup"></div><div id="sup"></div>';
  
  $('#html').html($inner);

Teardown



            // need something like this to reset target
  $('#html').empty().html($inner);
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
Remove
$('#sup').remove();
ready
Hide
$('#sup').hide();
ready
detach
$('#sup').detach();
ready
html('')
$('#html').html('');
ready
empty()
$('#html').empty();
ready
innerText = null
$("#html")[0].innerText = null;
ready
hybrid
var el = $("#html")[0];
while (el.firstChild) { el.removeChild(el.lastChild) }
ready

Revisions

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