I started reading about JavaScript patterns, and I really liked module pattern.So I created some module:var App = (function (parent, $) {    function myPrivateFunc () {        // Some private stuff    }    return {        myPubFunc: myPrivateFunc,        publicFunction: function () {            // Do some stuff        }    };})(App || {}, jQuery);Now I want to call some functions on page but only functions I need on that specific page. I got idea to add data-modules attribute to body, and then load modules I demanded on that attribute. I did that this way:var modules = $('body').data('modules').split( );for (var i = modules.length - 1; i >= 0; i--) {    App[modules[i]]();}My question is: Is this a good way to achieve what I wanted? I tested, it's working fine, but I'm a little suspicious about this dynamic calling. Is there better solutions (preferably not libraries) out there? If this is not good, why it isn't?
Dynamic call of module pattern function
javascript
Instead of adding data-properties to the body tag, and waiting for / relying on jQuery, just use an inline script:<script type=text/javascript>    var modules = /* echo the needed modules here */;    for (var i=0; i<modules.length; i++)        App[modules[i]]();</script>