Last modified: 2012-02-19 16:16:08 UTC
Currently there is a missleading message on any subpage of Common.js e.g. [[MediaWiki:Common.js/abc]]. BUT! I wouldn't like to see this fixed, but see this come true :-). If all of the subpages of Common.js would get auto included for users it would greatly ease adding new modules. It would then be logical (and possible) to combine this scripts into one file and might lower server load.
The message is not completely wrong, since it would be loaded for users with language "abc" if it wasn't a content language. And no, autoincluding all subpages won't happen. I'd love to be able of doing javascript inclusion, though.
> language "abc" if it wasn't a content language. a content *message*.
(In reply to comment #1) > And no, autoincluding all subpages won't happen. I'd love to be able of doing > javascript inclusion, though. You mean like importScript()? Closing as WONTFIX per comment #1.
In response to Nux, there is work underway to support what your getting at. Although the specific of transclution in js space won't happen. The scriptloader would let you include use a line in your common.js like: if( wgPageName == 'somePageThatNeedsMyModule' ){ mw.load( 'Some', 'Dependencies', 'WT:MediaWik:Mw.MyModule.js'){ // Your module is now available var MyModule = new mw,MyModule( { /* MyWikiConfigForMyModule */ } MyModule.updateUI(); }); } This way a single top level script contains all the configuration and included modules for a given wiki and any module set used in a given context is requested as a single package of javascript and css. If multiple modules are used in a given context your loader call could include both modules Some documentation was generated per gadget usage of this system in bug 23809
OK. I can see [[MediaWiki:Common.js/abc]] might be a problem (as in comment #1), but what about pages like [[MediaWiki:Common.js/My module.js]] or to be more exact MediaWiki:Common.js/*.js? Also note that importScript makes clearing browser cache very problematic (or almost impossible if you have importScript inside imported script)... Or will mw.load solve this too? Besides if it would compress modules then it would make thing even worse (JS compression in Open Source is IMHO just evil, sorry).
Thanks for your interest in addressing these issues. Yes, once things are going through the script-loader its easier to invalidate and update, it checks the revision ID of the text page to form wikitext urls on page renderings. Some tweaks could be made for it to work in the above described context. Javascript transclution even in the mediaWiki namespace is probably not a good idea. If used inline it will promote bad development paradigms. i.e: imagine in js: if( wgPageName == 'Specail:Upload' ){ {{{MediaWiki:Common.js/Upload.js}}} } Even if you just appended ScriptName.js/*.js to all scriptName requests, it does little for modularity over single long file, ( ie invalidates the top level cache on any underlining module change. It does not promote dynamic modules loaded per context, rather promotes large monolithic codebase invoked everywhere. Include subpages of Common.js to Common.js would break with existing conventions of loading where necessary of the existing mediaWiki:common.js files like: if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") //scripts specific to editing pages { importScript("MediaWiki:Common.js/edit.js") } else if (wgPageName == "Special:Watchlist") //watchlist scripts { importScript("MediaWiki:Common.js/watchlist.js") } Furthermore it makes it difficult to isolate and debug a particular script ( if you don't have an integrated way to get at the raw files in isolation.) mw.load bridges both use contexts by supporting direct reference to all the raw files in debug mode and single compressed packaged request in "scriptLoader" mode. JS compression saves a LOT on transport costs. With big javascript packages its a must. The user can always add a &debug or set a preference to get the raw version. No sense in sending hundreds of extra Kilobytes in non-minified javascript to people who will never know the difference other than what seems like slow site as they wait extra seconds for the js to load. If an error is shwoing up in minified version thats ~not~ present in the non-minified version then its an error with the minifier, and we want the minified line number not the source line number. We could include mention of the "debug" url param to request the non-minified in the header of all the js, retaining "open source reference to the code" for anyone that wanted to look at it.
(In reply to comment #0) > Currently there is a missleading message on any subpage of Common.js e.g. > [[MediaWiki:Common.js/abc]]. See also bug 31560.