Native XHR vs jQuery ajax

JavaScript performance comparison

Revision 12 of this test case created by

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.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
xhr2
// async test
var xhr = new XMLHttpRequest();
xhr.onload = function() {
  deferred.resolve();
}
xhr.open("GET", "https://jsonplaceholder.herokuapp.com/posts/1");
xhr.send(null);
pending…
jQuery ajax
// async test
var request = $.ajax({
  type: "GET",
  url: "https://jsonplaceholder.herokuapp.com/posts/1",
  success: function() {
    deferred.resolve();
  },
  data: null
});
pending…
Native XHR
// async test
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    deferred.resolve();
  }
}
xhr.open("GET", "https://jsonplaceholder.herokuapp.com/posts/1", true);
xhr.send(null);
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