Skip to content

Instantly share code, notes, and snippets.

@sebastien-p
Created December 18, 2011 17: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 sebastien-p/1493961 to your computer and use it in GitHub Desktop.
Save sebastien-p/1493961 to your computer and use it in GitHub Desktop.
jQuery (or Zepto) plugin AMD adapter
;!function(a,b,c){typeof(c=this.define)=="function"&&c.amd?c(a,b):b(this[(c=/(^|[/!,])(jquery|zepto)(,|!|$)/.exec(a))&&(c[2]=="zepto"?"Zepto":"jQuery")])}(["jquery"],function($){return $});
// Based on https://github.com/umdjs/umd
;!function (a, b, c) {
typeof (c = this.define) == "function" && c.amd ?
c(a, b) // Define call
:
// Globals fallback (dep. path can be something like "lib/dom/jquery").
// Search for the first jquery or zepto str. in the dep. array,
// if found, try to get the proper ref. from the global obj.
b(this[(c = /(^|[/!,])(jquery|zepto)(,|!|$)/.exec(a)) && (c[2] == "zepto" ? "Zepto" : "jQuery")])
} (
["jquery"], function ($) {
// Plugin stuff...
return $
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment