Skip to content

Instantly share code, notes, and snippets.

@maur8ino
Last active December 22, 2015 21:39
Show Gist options
  • Save maur8ino/6534535 to your computer and use it in GitHub Desktop.
Save maur8ino/6534535 to your computer and use it in GitHub Desktop.
Javascript module template
$(document).ready(function() {
// Calling module(s)
$M.myModule();
var module2 = new $M.myModule2();
module2.myPublicFunction();
if (someCondition) {
$M.myModule3();
}
});
(function() {
var myPrivateVar1,
myPrivateVar2;
function myModule() {
/*
Module init
*/
}
function myPrivateFunction() {
/*
private function logic
*/
}
myModule.prototype = {
myPublicFunction1: function(params) {
/*
can access private function/vars
*/
}
};
$M = window.$M || {};
$M.myModule = myModule;
window.$M = $M;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment