append vs html

JavaScript performance comparison

Test case created by Simon Arnold

Info

What is the most effective .append() or .html()

Preparation code

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

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
append
$('#test').append("Mauris purus augue, porttitor ac imperdiet ut, posuere non mi. Nam quis vestibulum tortor. Proin pretium, velit quis mattis mattis, erat sem ornare quam, vel pellentesque orci urna ut nibh. Aliquam lacus ipsum, blandit et leo eu, tincidunt mattis massa.")
pending…
html
$('#test').html("Mauris purus augue, porttitor ac imperdiet ut, posuere non mi. Nam quis vestibulum tortor. Proin pretium, velit quis mattis mattis, erat sem ornare quam, vel pellentesque orci urna ut nibh. Aliquam lacus ipsum, blandit et leo eu, tincidunt mattis massa.")
pending…

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

Compare results of other browsers

0 comments

Add a comment