Author: a.d.bergi
Description:
Today you only can load modules that are specified by MediaWiki, e.g. jQuery extensions, RL-Gadgets and mediawiki-utilities (legacies), and static uris with the ressource loader.
I already thought about registering user-script-modules, e.g. last lines of http://de.wikipedia.org/wiki/Benutzer:✓/js/deSecure.js. Here other scripts can use the mw.loader.using method, I chose "user.<usernick>.<scriptname>" for the module name analogous to "ext.<extensionname>", "jquery.<modulename>" etc. You already can use the mw.loader.register method to set dependencies, load some system messages per api, specifiy css (or load from api) and design a to-be-executed function, and then mw.loader.implement() them to your module.
But this needs up to 3 file loads (script file with function, dependencies and implementation; messages api; css file) and is used by a call of mw.loader.load(<static url of script file>). Also the dependencies don't work as you use other user scripts, which would cause a request ending up in state:missing when they're not loaded then and preventing the real implentation by that.
A better way would be loading them one-in-all (and not module by module, see T28291), just by one simple module request that specifies project (+project language), user, module name and i18n (message language, by default uselang).
Of course for detecting every modules' messages and dependencies either a auxiliary page (like in the Gadget extension) or a preprocessing of the script page would be needed. I'd propose the latter, this could be done like a /* comment */ at the top of the page where the module creator can specify dependencies, messages and CSS-pages to be embedded in one call of loader.implement. The function would be either a also specified one or the rest of the script.
Version: unspecified
Severity: enhancement