Last active
August 29, 2015 14:06
-
-
Save JamesWP/4fbfdc73415702d15191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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