new Image vs createElement vs cloneNode image

Benchmark created by Cezary Tomczyk on


Preparation HTML

<script>
  var imageElement1, imageElement2, imageElement3, img = document.createElement("img");
img.width = 20;
img.height = 20;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
createElement
imageElement1 = document.createElement('img');
imageElement1.width = 20;
imageElement1.height = 20;
ready
cloneNode
imageElement2 = img.cloneNode(false);
ready
new Image
imageElement3 = new Image();
imageElement3.width = 20;
imageElement3.height = 20;
ready

Revisions

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

  • Revision 1: published by Cezary Tomczyk on