Skip to content

Instantly share code, notes, and snippets.

@nickjacob
Created September 20, 2012 01:12
Show Gist options
  • Save nickjacob/3753396 to your computer and use it in GitHub Desktop.
Save nickjacob/3753396 to your computer and use it in GitHub Desktop.
Basic Javascript Template
/**
* This is my own idea of how I wish all javascript files looked. I don't think it's probably the "best" way (is there a *best* way?), but I like it
* and I think everyone should have some kind of style.
*/
// name the IIFE for debugging/organization if you want to use a concatenation build tool
;(function this_module(window,undefined){
var _public = {}, _private = {}; // if only it were real!!! Fun fact -- "public" is reserved!
_public.public_func = function(){}; // etc
_public.my_var = "lol";
// here you could apply a decorator to all or some public functions..
my_export = my_export || {};
my_export.this_module = _public; // I prefer to doing this to returning so the outer closure is more independent :)
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment