Skip to content

Instantly share code, notes, and snippets.

@slikts
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slikts/11050304 to your computer and use it in GitHub Desktop.
Save slikts/11050304 to your computer and use it in GitHub Desktop.
Ping a server with HEAD requests until it's up and then reload
function reload(url, delay) {
url = url || '/';
delay = delay || 10;
var req = new XMLHttpRequest();
req.onload = window.location.reload.bind(window.location);
req.onerror = setTimeout.bind(null, reload.bind(null, url, delay), delay);
req.open('head', url, true);
req.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment