Created
November 7, 2011 07:14
-
-
Save jrburke/1344389 to your computer and use it in GitHub Desktop.
possible jquery plugin boilerplate
This file contains hidden or 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
// Basic approach. Does not try to register in | |
// a CommonJS environment since jQuery is not likely | |
// to run in those environments. See next file | |
// if you want to opt in to CommonJS too. | |
(function(factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function($) { | |
$.fn.myPlugin = function () {}; | |
})); |
This file contains hidden or 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
// Includes registering in a CommonJS environment, | |
// but it is unlikely jQuery will run in a CommonJS | |
// environment. See other file if you do not want | |
// optional CommonJS registration. | |
(function(factory) { | |
if (typeof exports === 'object') { | |
// Node/CommonJS | |
factory(require('jquery')); | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function($) { | |
$.fn.myPlugin = function () {}; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jrburke, I guess that makes sense. It it using the full path as the module name.