xhr image loading

Benchmark created by Broofa on


Preparation HTML

<img id="dst" />

Setup

xhr = new XMLHttpRequest();
    img = document.getElementById('dst');
    url = 'https://2.gravatar.com/avatar/b072fc2897196b3bafcd337bc9c91e2d?s=140';

Test runner

Ready to run.

Testing in
TestOps/sec
set to remote url
xhr.open('GET', url);
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    img.src = url;
  }
}
xhr.send();
ready
set to data url
// async test
xhr.open('GET', url);
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    img.src = 'data:image/jpeg;base64' + atob(xhr.responseText);
  }
}
xhr.send();
ready

Revisions

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

  • Revision 1: published by Broofa on