Situation:
- ResourceLoader wraps modules in closures
- MediaWiki developers put a closure in each file
- As a result loading 1 module with 2 files will have 3 closures
mw.loader.implement( 'foo', function ( $ ) { --- foo.a.js ( function ( $, mw ) { ... }( jQuery, mediaWiki ) ) --- foo.b.js ( function ( $, mw ) { ... }( jQuery, mediaWiki ) ) } ); inside mw.loader#execute: script( jQuery );
It has been suggested we add "mw" to ResourceLoader's closure and get rid of the per-file closure.
The downside of doing that would be that they are less safe to use "standalone". e.g. a jquery plugin would be using $ directly, which, outside MediaWiki ResourceLoader context is bad.
There is also the pending refactoring of ResourceLoader debug mode to not be completely different and near useless by executing in the global scope.