Plugin development : private and public functions, where really to place them ?

Plugin development : private and public functions, where really to place them ?


Hi,
I'm new in JS/jQuery development and i need your help about a
question : where really to place private and public functions ?
I saw various possibilities on the net, but two seems to be identical.
For example, public function. The first possibility :
;(function($) {
var $.fn.pluginName = function(options) {
var opts = $.extend({}, $.fn.pluginName.defaults,
options);
// public function inside $.fn.pluginName function
var $.fn.pluginName.publicFunction = function(args) {
// CODE ...
};
// CODE ...
return this.each( function() {
// CODE ...
});
};
})(jQuery);
The second possibility :
;(function($) {
var $.fn.pluginName = function(options) {
var opts = $.extend({}, $.fn.pluginName.defaults,
options);
// CODE ...
return this.each( function() {
// CODE ...
});
};
// public function inside (function($) { ... })(jQuery)
var $.fn.pluginName.publicFunction = function(args) {
// CODE ...
};
})(jQuery);
What is the best ? Are they different ?
The same question existe about private functions. First :
;(function($) {
var $.fn.pluginName = function(options) {
var opts = $.extend({}, $.fn.pluginName.defaults,
options);
// private function inside "$.fn.pluginName" function
var privateFunction = function(args) {
// CODE ...
};
// CODE ...
return this.each( function() {
// CODE ...
});
};
})(jQuery);
And the second possibility :
;(function($) {
var $.fn.pluginName = function(options) {
var opts = $.extend({}, $.fn.pluginName.defaults,
options);
// CODE ...
return this.each( function() {
// CODE ...
});
};
// private function outside "$.fn.pluginName" function
var privateFunction = function(args) {
// CODE ...
};
})(jQuery);
Really thanks for your help,