createElement vs cloneNode (v6)

Revision 6 of this benchmark created on


Description

Creating a node with couple of style attributes

Preparation HTML

<script>
  var masterDiv = document.createElement('div');
  masterDiv.style.position = "absolute";
  masterDiv.style.cursor = "pointer";
  masterDiv.style.overflow = "hidden";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
createElement
var div1 = document.createElement('div');
div1.style.position = "absolute";
div1.style.cursor = "pointer";
div1.style.overflow = "hidden";
div1.style.left = "0px";
div1.style.top = "0px";
div1.style.width = "100px";
div1.style.height = "100px";
document.body.appendChild(div1);
document.body.removeChild(div1);
ready
cloneNode
var div2 = masterDiv.cloneNode(true);
div2.style.left = "0px";
div2.style.top = "0px";
div2.style.width = "100px";
div2.style.height = "100px";
document.body.appendChild(div2);
document.body.removeChild(div2);
ready

Revisions

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