jQuery .remove vs. .hide (v48)

Revision 48 of this benchmark created by Dan on


Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div id="remove-me"></div>
<div id="hide-me"></div>
<script>
  function init() {
   // The magic init() function will be executed once before every test
   // Still not perfect, but definitely better
   $('<div id="remove-me" />').appendTo('body');
   $('#hide-me').show();
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.hide()
$('#hide-me').hide();
ready
.addClass('hidden')
$('#hide-me').addClass('hidden');
ready
.remove()
window.setTimeout(function() {
$('#remove-me').remove();
}, 5);
ready

Revisions

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