Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Created October 30, 2013 20:09
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 terinjokes/7239380 to your computer and use it in GitHub Desktop.
Save terinjokes/7239380 to your computer and use it in GitHub Desktop.
Friendlier jQuery in CommonJS enivronments
(function(fn) {
function setup($) {
return $.fn.extend(fn(jQuery));
}
if (typeof exports === 'object') {
module.exports = setup;
} else {
setup(jQuery || Zepto);
}
}(function($) {
return {
gmap: function() {
this.each(function(index, elem) {
$(elem).append('<pre>GMaps</pre>');
});
},
gnoop: function() {}
}
}))
(function(fn) {
function setup($) {
return $.fn.gmap = fn($);
}
if (typeof exports === 'object') {
module.exports = setup
} else {
setup(jQuery || Zepto);
}
}(function($) {
return function() {
this.each(function(index, elem) {
$(elem).append('<pre>GMaps</pre>');
});
}
}))
@toekneestuck
Copy link

In multiple.jquery.js, shouldn't it be $.fn.extend($) instead of $.fn.extend(jQuery) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment