Skip to content

Instantly share code, notes, and snippets.

@sagarsane
Created September 10, 2012 02:25
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagarsane/3688474 to your computer and use it in GitHub Desktop.
Save sagarsane/3688474 to your computer and use it in GitHub Desktop.
Self calling functions + setTimeout instead of setInterval
/*
This is very useful and smoother (feels like at least) when you want to do something like live updates on the UI or something (thinking Windows 8 UI styling?)
*/
(function better(){
//logic here
setTimeout(better, 100);
})();
/*
This will ensure that the function is called only after the logic executes (which can sometimes be a problem in setInterval
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment