createElement vs cloneNode (v5)

Revision 5 of this benchmark created by Terry Anastasiadis on


Preparation HTML

<script>
    var divTemplate = function() {
        var div = document.createElement('div'),
            divStyle = div.style,
            childH1 = document.createElement('h1'),
            childP = document.createElement('p'),
            childSpan = document.createElement('span');;

        divStyle.position = "absolute";
        divStyle.cursor = "pointer";
        divStyle.overflow = "hidden";

        div.appendChild(childH1);
        div.appendChild(childP);
        div.appendChild(childSpan);
        
        return div;
    },
    masterDiv = divTemplate(); 
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
createElement
var div = divTemplate();
ready
cloneNode
var div = masterDiv.cloneNode(true);
ready

Revisions

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