Skip to content

Instantly share code, notes, and snippets.

@djKianoosh
Created August 15, 2015 20:12
Show Gist options
  • Save djKianoosh/18b63266a5736f67bf4a to your computer and use it in GitHub Desktop.
Save djKianoosh/18b63266a5736f67bf4a to your computer and use it in GitHub Desktop.

Javascript universal module format

myModule depends on lodash and jquery, for example

(function (root, definition) {
var _module_name = "myModule";
if (typeof define === 'function' && define.amd) {
define(['jquery', 'lodash'], function($, _){
return (root[_module_name] = definition($, _));
});
} else {
root[_module_name] = definition($, _);
}
}(this, function ($, _, undefined) {
'use strict';
return {};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment