Skip to content

Instantly share code, notes, and snippets.

@dedg3
Created January 10, 2013 14:23
Show Gist options
  • Save dedg3/4502361 to your computer and use it in GitHub Desktop.
Save dedg3/4502361 to your computer and use it in GitHub Desktop.
Javscript Sleep Function
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
// Usage
sleep(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment