Skip to content

Instantly share code, notes, and snippets.

@rndme
Created September 16, 2019 18:12
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 rndme/1858443728a59279932796dfcf08078c to your computer and use it in GitHub Desktop.
Save rndme/1858443728a59279932796dfcf08078c to your computer and use it in GitHub Desktop.
A browser js timer that won't be suspended when the tab is not active
var worker = new Worker('data:text/javascript,' + escape("setInterval(postMessage.bind(this,0), 1000)"));
worker.onmessage=console.info.bind(console); // attach your interval callback here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment