Ajax JSONP vs Ajax JSON (v12)

Revision 12 of this benchmark created on


Description

Ajax JSONP vs Ajax JSON

Preparation HTML

<div id="content">
</div>

Setup

window['callback'] = function (data) {
      document.getElementById('content').innerHTML = JSON.stringify(data);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Ajax JSONP
var b = document, a = b.createElement('SCRIPT');
a.async = true;
a.src = 'http://jsperf.com/api/jsonp';
b.body.appendChild(a);
ready
Ajax JSON
var b = new XMLHttpRequest
b.open('GET', 'http://jsperf.com/api/json', true);
b.onreadystatechange = function () {
  if (4 == b.readyState && 200 == b.status) {
    var a = JSON.parse(b.responseText);
    callback(a);
  }
};
b.send();
ready

Revisions

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