cloneNode vs createElement Performance (v7)

Revision 7 of this benchmark created on


Description

check speeds with different elements

Preparation HTML

<script>
  var img = document.createElement("img");
  img.src = "http://www.google.com/intl/en_com/images/srpr/logo2w.png";
  
  var div = document.createElement("div");
  div.className = "myclass1 myclass2";
  
  var input = document.createElement("input");
  input.type = "checkbox";
  input.className = "myinputclass";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
clone image
var imgClone = img.cloneNode(false);
ready
create image
var img = document.createElement("img");
img.className = "myinputclass";
img.src = "http://www.google.com/intl/en_com/images/srpr/logo2w.png";
 
ready
clone div
var divClone = div.cloneNode(false);
ready
create div
var div = document.createElement("div");
div.className = "myclass1 myclass2";
 
ready
clone input
var inputClone = input.cloneNode(false);
ready
create input
var input = document.createElement("input");
input.type = "checkbox";
input.className = "myinputclass";
ready
new image
var img2 = new Image();
img2.src = "http://www.google.com/intl/en_com/images/srpr/logo2w.png";
ready

Revisions

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