Add support for loading mediawiki.util from the top by default
authorKrinkle <krinkle@users.mediawiki.org>
Sun, 29 Jan 2012 19:40:11 +0000 (19:40 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sun, 29 Jan 2012 19:40:11 +0000 (19:40 +0000)
* 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

RELEASE-NOTES-1.19
includes/DefaultSettings.php
includes/OutputPage.php
resources/Resources.php

index 92ff7df..80ca445 100644 (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 ==
 
index 6d588f7..20e43ab 100644 (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:
index 70a8c53..16e158d 100644 (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' );
index 1830ba9..42dfb41 100644 (file)
@@ -592,6 +592,7 @@ return array(
                        'jquery.mwExtension',
                ),
                'messages' => array( 'showtoc', 'hidetoc' ),
+               'position' => 'top', // For $wgPreloadJavaScriptMwUtil
        ),
 
        /* MediaWiki Action */