Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A universal definition pattern for JavaScript libraries. Supports require(), AMD, and browser.
;(function() {
function myModule() {
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = myModule;
}
else {
if (typeof define === 'function' && define.amd) {
define([], function() {
return myModule;
});
}
else {
window.myModule = myModule;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.