InnerHTML vs html

JavaScript performance comparison

Test case created and last updated

Preparation code

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

<div id="myDiv">
 
</div>

<script>
//for(var i = 0; i<5000; i++){
//$('div').appendTo('#myDiv');
//}
</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
innerHTML
$('#myDiv')[0].innerHTML = '<div>test</div>';
pending…
jquery.html
$('#myDiv').html('<div>test</div>');
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