Native XHR vs jQuery ajax vs get (v3)

Revision 3 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
Native XHR
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
  if (xhr.readyState == 4) {"done"}
}
xhr.open("GET", "http://jsperf.com", true);
xhr.send(null);
ready
xhr2
var xhr = new XMLHttpRequest();
xhr.onload = function() {"done"}
xhr.open("GET", "http://jsperf.com");
xhr.send(null);
ready
jQuery ajax
var request = $.ajax({  success: function() {
  alert(1);
}});
ready
jQuery get1
var request = $.get().done(function() {
  alert(1);
});
ready
jQuery get12
var request = $.get("").done(function() {
  alert(1);
});
ready
xhr3
var xhr = new XMLHttpRequest();
xhr.onload = function() {alert(1)};
xhr.open("get", true);
xhr.send();
ready

Revisions

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