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

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -