jquery - empty vs html (v17)

Revision 17 of this benchmark created on


Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<div id="foo">foo bar foo bar foo bar foo bar</div>
<script>
  var foo = $('#foo');

  jQuery.fn.removeAll = function() {
   this.each(function() {
    var newEl = this.cloneNode(false);
   if (this.parentNode) this.parentNode.replaceChild(newEl, this);
     });
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
empty
foo.empty();
ready
html
foo.html('');
ready
innerHTML
foo[0].innerHTML = '';
ready
removeAll
foo.removeAll();
ready

Revisions

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