Skip to content

Instantly share code, notes, and snippets.

@jussi-kalliokoski
Created July 15, 2011 14:24
Show Gist options
  • Save jussi-kalliokoski/1084782 to your computer and use it in GitHub Desktop.
Save jussi-kalliokoski/1084782 to your computer and use it in GitHub Desktop.
Small sleep function for JavaScript
/**
* Does nothing (useful) for a specified time.
*
* @param {Uint} The time to sleep, in milliseconds.
*/
function sleep(t){var m=+new Date+t;while(+new Date<m);}
// Please note that this is a pattern that is hardly useful, never advisable and a bit intensive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment