outerHTML vs jQuery clone hack (v2)

Revision 2 of this benchmark created on


Preparation HTML

<div id="test">
<p>foo</p>
<p>bar</p>
</div>

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

Test runner

Ready to run.

Testing in
TestOps/sec
outerHTML
var x = document.getElementById('test').outerHTML;
ready
jQuery Clone-then-Wrap
var x = $('#test').clone().wrap('<p>').parent().html();
ready
jQuery create-and-append
var x = $('<p/>').append($('#test').clone()).html()
ready

Revisions

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