new Image vs createElement vs cloneNode image

JavaScript performance comparison

Test case created by Cezary Tomczyk

Preparation code

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
createElement
imageElement1 = document.createElement('img');
imageElement1.width = 20;
imageElement1.height = 20;
pending…
cloneNode
imageElement2 = img.cloneNode(false);
pending…
new Image
imageElement3 = new Image();
imageElement3.width = 20;
imageElement3.height = 20;
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. Here’s a list of current revisions for this page:

0 comments

Add a comment