Created
November 15, 2021 02:40
-
-
Save lynsei/95f01d6ddf9097d2986b68304a5d22e2 to your computer and use it in GitHub Desktop.
This is a UMS Plugin beingn created for jQuery, following the UMD spec here: https://github.com/umdjs/umd
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
// Uses CommonJS, AMD or browser globals to create a jQuery plugin. | |
(function (factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else if (typeof module === 'object' && module.exports) { | |
// Node/CommonJS | |
module.exports = function( root, jQuery ) { | |
if ( jQuery === undefined ) { | |
// require('jQuery') returns a factory that requires window to | |
// build a jQuery instance, we normalize how we use modules | |
// that require this pattern but the window provided is a noop | |
// if it's defined (how jquery works) | |
if ( typeof window !== 'undefined' ) { | |
jQuery = require('jquery'); | |
} | |
else { | |
jQuery = require('jquery')(root); | |
} | |
} | |
factory(jQuery); | |
return jQuery; | |
}; | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function ($) { | |
$.fn.jqueryPlugin = function () { return true; }; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment