javascript - Using multiple IIFEs in one script file -


i'm working on script file original author has multiple iifes wrapped in one. descendant iifes written use-cases. example there might 1 search functionality, navbar, etc.:

(function($) {   (function() {     var $search = $(".search");      $search.on("focus", function() {       //     });   }());    (function() {     var $nav     = $(".nav"),         $navlink = $(".nav__link");      $navlink.on("click", function() {       //     });   }());    // more iifes }(jquery)); 

is there benefit in doing this? overall redundant create iifes every action?

what developer has done purely stylistic approach. separated different parts of ui initialization functions need execute. further info why developer separated them in way instead of naming method each , executing method within context have ask developer himself.


Comments

Popular posts from this blog

angularjs - Redirect to a new template in angular js -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

Desktop Launcher for Python Script Starts Program in Wrong Path (Linux) -