Native XHR vs jQuery ajax (v25)

Revision 25 of this benchmark created by Emanuele Sabellico on


Preparation HTML

<script src="http://code.jquery.com/jquery-2.1.4.min.js">
</script>
<script src="https://raw.githubusercontent.com/github/fetch/master/fetch.js"></script>

Setup

window.done = function(){ deferred.resolve()}
  window.url = 'https://raw.githubusercontent.com/github/fetch/master/fetch.js'

Test runner

Ready to run.

Testing in
TestOps/sec
fetch
// async test
fetch(url).then(done)
ready
Native XHR
// async test
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    done(xhr);
  }
}
xhr.send();
ready
Native XHR Onload
// async test
var xhr = new XMLHttpRequest();
xhr.onload = done;
xhr.open("GET", url, true);
xhr.send(null);
ready
jQuery ajax
// async test
var request = $.get(url, done);
ready

Revisions

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