Skip to content

Instantly share code, notes, and snippets.

@amiel
Created September 28, 2010 22:54
Show Gist options
  • Save amiel/601965 to your computer and use it in GitHub Desktop.
Save amiel/601965 to your computer and use it in GitHub Desktop.
var this_will_only_run_once = (function() {
var has_been_run = false; // this private variable will be kept between runs, but doesn't pollute the global namespace
return function() {
if (has_been_run) return; has_been_run = true;
// do stuff here, it will only be run once
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment