Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created January 8, 2010 20:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cowboy/272407 to your computer and use it in GitHub Desktop.
Save cowboy/272407 to your computer and use it in GitHub Desktop.
View revisions from oldest -> newest
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways.
(function($){
var private_var;
$.myNS = {
public_method1: function(){
private_method();
},
public_method2: function(){
return private_var;
}
};
function private_method() {
$.myNS.public_method2();
}
})(jQuery);
// 143 bytes compressed
// (function(a){var c;a.myNS={public_method1:function(){b()},public_method2:function(){return c}};function b(){a.myNS.public_method2()}})(jQuery);
//
// object literal used to define methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment