Skip to content

Instantly share code, notes, and snippets.

@JamesWP
Last active August 29, 2015 14:06
Show Gist options
  • Save JamesWP/4fbfdc73415702d15191 to your computer and use it in GitHub Desktop.
Save JamesWP/4fbfdc73415702d15191 to your computer and use it in GitHub Desktop.
function makeRequest(url) {
httpRequest = new XMLHttpRequest();
var start = new Date().getTime();
var stopTimer = function(){
if (httpRequest.readyState == 4){
var time = new Date().getTime() - start;
document.write(time<100?".":(time>600?" ":"-"));
console.log(time);
makeRequest(url);
};
}
httpRequest.onreadystatechange = stopTimer;
httpRequest.open('GET', url + '?_' + Math.random());
httpRequest.send();
}
makeRequest('/puzzle');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment