Quick DOM Image Creation Test

Benchmark created by Matt McDonald on


Description

Testing the speed of various methods of image creation + appending via the DOM.

Preparation HTML

<div id="foo"></div>
<script>
  var img, foo = document.getElementById("foo");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
HTMLDocument.createElement(tagName)
img = document.createElement("img");
foo.appendChild(img);
foo.removeChild(img);
ready
Image Constructor
img = new Image();
foo.appendChild(img);
foo.removeChild(img);
ready
innerHTML
img = "<img src=\"\" \/>";
foo.innerHTML = img;
foo.innerHTML = "";
ready

Revisions

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

  • Revision 1: published by Matt McDonald on