Skip to content

Instantly share code, notes, and snippets.

@stevenschobert
Last active December 25, 2015 19:09
Show Gist options
  • Save stevenschobert/7025958 to your computer and use it in GitHub Desktop.
Save stevenschobert/7025958 to your computer and use it in GitHub Desktop.
Pattern for exporting a plain JS module (when not using AMD/CommonJS). Pulled from O'Reilly's "Programming JavaScript Applications".
// Optional object namespace
var app = {};
(function (exports) {
(function (exports) {
// module exports
exports.moduleName = {
};
}((typeof exports === 'undefined') ?
window : exports));
}(app));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment