xhr-vs-jq-fetch

JavaScript performance comparison

Test case created by hemanth

Preparation code

<script src="https://code.jquery.com/jquery-latest.min.js">
</script>
 
    

Preparation code output

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
XHR
// async test
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {
    deferred.resolve();
  }
}
xhr.open("GET", "https://dog.ceo/api/breeds/image/random", true);
xhr.send(null);
pending…
fetch
// async test
var request = fetch('https://dog.ceo/api/breeds/image/random')
.then(_ => deferred.resolve())
.catch(console.error);
pending…
jq
// async test
var request = $.ajax({
    type: "GET",
    url: "https://dog.ceo/api/breeds/image/random",
    success: function() { deferred.resolve(); },
    data: null
});
pending…

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

Compare results of other browsers

0 Comments