Lazy Loading Content

JavaScript performance comparison

Revision 3 of this test case created by Kyle Simpson

Preparation code

<div id="comment-panel"><!-- <img src='rodent.jpg' id='img' /> --></div>
<script type='text/html' id='script-panel-clean-img'><img src='rodent.jpg' id='img' /></script>

<div id="target_1"></div><div id="target_2"></div><div id="target_3"></div><div id="target_4"></div>

<script>

var source_1 = "<img src='rodent.jpg' id='img' />";
var source_2 = document.getElementById("comment-panel");
var source_3 = document.getElementById("script-panel-clean-img");

var target_1 = document.getElementById("target_1");
var target_2 = document.getElementById("target_2");
var target_3 = document.getElementById("target_3");
var target_4 = document.getElementById("target_4");

</script>
    

Preparation code output

<div id="comment-panel"><!-- <img src='rodent.jpg' id='img' /> --></div> <div id="target_1"></div><div id="target_2"></div><div id="target_3"></div><div id="target_4"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Doc Frag
target_1.innerHTML = source_1;
pending…
Comment
target_2.innerHTML = source_2.innerHTML.slice(5,-3);
pending…
Script w/ Code Outside Div
target_3.innerHTML = source_3.text;
pending…
Comment Using NodeType
target_4.innerHTML = source_2.childNodes[0].nodeValue;
pending…

Compare results of other browsers

Revisions

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

0 Comments