.append($) vs { html : ''}

Benchmark created by Dan on


Description

Testing the speed of $("<foo/>").append($("<em/>")) vs $("<foo/>", { html: '<em></em>' })

Preparation HTML

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

<div id="sup">
  I am a div
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
.append( $('<em/>') )
$("#sup").append(
    $('<span/>').append($('<em/>'))
)
ready
{ 'html': '<em></em>' }
$("#sup").append(
    $('<span/>', { 'html': '<em></em>' })
)
ready

Revisions

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