Answer the question
In order to leave comments, you need to log in
Why (function($){…})(jQuery)?
Why is it customary to write:
(function($) {
$.fn.mySimplePlugin = function(){
// код плагина ...
return this;
};
})(jQuery);
$.fn.mySimplePlugin = function($){
// код плагина ...
return this;
};
Answer the question
In order to leave comments, you need to log in
The (function($){…})(jQuery) construct isolates the plugin's namespace. This is a guarantee that the plugin will not overwrite someone else's variable, for example.
To shut up the holey scope model in JS.
In modern JS, this is not necessary: modules and let fixed the problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question