Skip to content

Instantly share code, notes, and snippets.

@Scooletz
Created June 24, 2013 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Scooletz/5853696 to your computer and use it in GitHub Desktop.
Save Scooletz/5853696 to your computer and use it in GitHub Desktop.
This is a snippet of a nice introducing modules to your js code.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD is found. Use it to register as anonymous module.
define(['jquery'], factory);
} else {
// AMD is not found, use a standard module patter
factory(jQuery);
}
}(function ($) {
// use $ safetly, it's provided either by AMD or a simple module patter
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment