Created
June 24, 2013 21:18
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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