Say I have this module and I want it to self initialize and attach to its scope. Like so:

(function( scope ) { var Module = (function() { return { init: function(){ console.log('Initialized'); } }; })(); var module = scope.Module = Module; module.init(); })( self );

Now, the problem is, is that self is always the window . I don't want that. I want it to be the scope of where it's been invoked and loaded by jQuery's $.getScript() , like so:

var Master = (function($) { return { init: function() { var self = this; $.getScript("/js/libs/module.js"); } } })(jQuery)

Is there a way to crack this?