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

Revision 39 of this benchmark created by Heavensrevenge 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

Revisions

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