Add support for loading mediawiki.util from the top by default

* Introduces $wgPreloadJavaScriptMwUtil
* Instead of loading mediawiki.util as base module from the bottom, now loading it from queue position "top" if $wgPreloadJavaScriptMwUtil is true. And if false it'll remain in the bottom in practice as implied by other modules loading it as a dependency (i.e. mediawiki.page.ready depends on it)
* Fixes bug 33746
This commit is contained in:
Krinkle 2012-01-29 19:40:11 +00:00
parent d70c7e6b28
commit 3c72b527ed
4 changed files with 27 additions and 2 deletions

View file

@ -321,6 +321,13 @@ changes to languages because of Bugzilla reports.
* Support for the deprecated hook MagicWordMagicWords was removed.
* The Xml::namespaceSelector method has been deprecated, please use
Html::namespaceSelector instead (note that the parameters have changed also).
* (bug 33746) Preload popular ResourceLoader modules (mediawiki.util) as stop-gap
for scripts missing dependencies.
New configuration variable $wgPreloadJavaScriptMwUtil has been introduced for this
(set to false by default for new installations). Set to true if your wiki has a large
amount of user/site scripts that are lacking dependency information. In the short to
medium term these user/site scripts should be fixed by adding the used modules to the
dependencies in the module registry and/or wrapping them in a callback to mw.loader.using.
== Compatibility ==

View file

@ -2604,6 +2604,19 @@ $wgResourceLoaderMinifierMaxLineLength = 1000;
*/
$wgIncludeLegacyJavaScript = true;
/**
* Whether to preload the mediawiki.util module as blocking module in the top queue.
* Before MediaWiki 1.19, modules used to load slower/less asynchronous which allowed
* modules to lack dependencies on 'popular' modules that were likely loaded already.
* This setting is to aid scripts during migration by providing mediawiki.util
* unconditionally (which was the most commonly missed dependency).
* It doesn't cover all missing dependencies obviously but should fix most of them.
* This should be removed at some point after site/user scripts have been fixed.
* Enable this if your wiki has a large amount of user/site scripts that are lacking
* dependencies.
*/
$wgPreloadJavaScriptMwUtil = false;
/**
* Whether or not to assing configuration variables to the global window object.
* If this is set to false, old code using deprecated variables like:

View file

@ -2439,12 +2439,12 @@ $templates
* Add the default ResourceLoader modules to this object
*/
private function addDefaultModules() {
global $wgIncludeLegacyJavaScript, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
$wgAjaxWatch, $wgEnableMWSuggest;
// Add base resources
$this->addModules( array(
'mediawiki.user',
'mediawiki.util',
'mediawiki.page.startup',
'mediawiki.page.ready',
) );
@ -2452,6 +2452,10 @@ $templates
$this->addModules( 'mediawiki.legacy.wikibits' );
}
if ( $wgPreloadJavaScriptMwUtil ) {
$this->addModules( 'mediawiki.util' );
}
// Add various resources if required
if ( $wgUseAjax ) {
$this->addModules( 'mediawiki.legacy.ajax' );

View file

@ -592,6 +592,7 @@ return array(
'jquery.mwExtension',
),
'messages' => array( 'showtoc', 'hidetoc' ),
'position' => 'top', // For $wgPreloadJavaScriptMwUtil
),
/* MediaWiki Action */