cloneNode vs createElement Performance

JavaScript performance comparison

Revision 26 of this test case created by

Preparation code

<script> 
function createErrorElement() {
                var errorElement = document.createElement("tr");
                var tableCell_1 = document.createElement("td");
                tableCell_1.setAttribute("class", "formErrors");
                tableCell_1.innerHTML = "&nbsp;";
                var tableCell_2 = document.createElement("td");
                tableCell_2.setAttribute("class", "formErrors");
                var span = document.createElement("span");
                span.setAttribute("class", "errMsg");
                span.appendChild(document.createTextNode('You must specify a value for this field.'));
                tableCell_2.appendChild(span);
                errorElement.appendChild(tableCell_1);
                errorElement.appendChild(tableCell_2);
                return errorElement;
            }
  var errorElement = createErrorElement();
</script>
    

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
clone element
errorElement.cloneNode(true);
pending…
create element
createErrorElement()
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