Skip to content

Instantly share code, notes, and snippets.

@gcpantazis
Created September 3, 2014 20:44
Show Gist options
  • Save gcpantazis/4d5bf949c3f910bb00b6 to your computer and use it in GitHub Desktop.
Save gcpantazis/4d5bf949c3f910bb00b6 to your computer and use it in GitHub Desktop.
Component / plugin definition pattern
(function() {
var MyModule = function() {
// ...
}
// Browserify / CommonJS
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = MyModule;
// RequireJS / AMD
} else if (typeof define === "function" && define.amd) {
define("MyModule", [], MyModule);
// Old Skool
} else {
window.MyModule = MyModule;
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment