Fastest way to get AJAX function (xmlhttp) (v3)

Revision 3 of this benchmark created by Tri on


Description

Look for the correct xmlhttp function OR get a xmlhttp function and get the other one if it failed

Test runner

Ready to run.

Testing in
TestOps/sec
Asking for permission
var http_request = false;
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
ready
Asking for forgiveness (Tertiary)
var x = this.ActiveXObject;
x = new(x ? x : XMLHttpRequest)('Microsoft.XMLHTTP');
ready
test 3
var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
ready
test 4
var x=new(window.XMLHttpRequest||ActiveXObject)('Microsoft.XMLHTTP')
ready
test 5
var x;

try {
 x = new XMLHttpRequest();

}

catch(e) {
x = new ActiveXObject("Microsoft.XMLHTTP");
}
ready

Revisions

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