jQuery.html() vs jQuery.append() vs jQuery.prepend() (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<div id="test-wrapper"><span id="text">text</span></div>

Setup

var html = '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>';

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery html
$('#test-wrapper').html(html);
ready
jQuery append
$('#test-wrapper').append($(html));
ready
jQuery prepend
$('#test-wrapper').prepend($(html));
ready

Revisions

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