Native XHR vs jQuery ajax

JavaScript performance comparison

Revision 19 of this test case created by kalle

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://raw.githubusercontent.com/github/fetch/master/fetch.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  function done(data) {
      alert(data);
  }
  var url = 'https://www.yandex.ru/portal/home-touch/service-worker.js';

};
</script>

Preparation code output

<script src="https://raw.githubusercontent.com/github/fetch/master/fetch.js"></script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Native XHR
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    done(xhr);
  }
}
xhr.open("GET", url, true);
xhr.send(null);
pending…
jQuery ajax
var request = $.ajax({
  type: "GET",
  url: url,
  success: done,
  data: null
});
pending…
Native XHR onload
var xhr = new XMLHttpRequest();
xhr.onload = done;
xhr.open("GET", url, true);
xhr.send(null);
pending…
fetch
fetch(url).then(done)
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.

0 Comments