jquery - empty vs html (v13)

Revision 13 of this benchmark created by paul on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="foo"><div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div>
<div>
        <h1>Hello World</h1>
        <p>How are you?</p>
</div></div>
<script>
  var foo = $('#foo'),
foo_inner = $('#lol');
</script>

Test runner

Ready to run.

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

Revisions

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