Index: branches/resourceloader/phase3/includes/OutputPage.php |
— | — | @@ -2312,19 +2312,12 @@ |
2313 | 2313 | global $wgUser, $wgRequest, $wgJsMimeType; |
2314 | 2314 | global $wgStylePath, $wgStyleVersion; |
2315 | 2315 | |
| 2316 | + // Statup - this will immediately load jquery and mediawiki modules |
2316 | 2317 | $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts' ); |
| 2318 | + // Configuration |
| 2319 | + $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; |
2317 | 2320 | // Support individual script requests in debug mode |
2318 | 2321 | if ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) !== 'false' ) { |
2319 | | - // Configuration |
2320 | | - $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; |
2321 | | - // Messages |
2322 | | - foreach ( $this->getModuleMessages() as $name ) { |
2323 | | - $scripts .= self::makeResourceLoaderLink( $sk, $name, 'messages' ); |
2324 | | - } |
2325 | | - // Modules |
2326 | | - foreach ( $this->getModules() as $name ) { |
2327 | | - $scripts .= self::makeResourceLoaderLink( $sk, $name ); |
2328 | | - } |
2329 | 2322 | // Styles |
2330 | 2323 | foreach ( $this->getModuleStyles() as $name ) { |
2331 | 2324 | $scripts .= self::makeResourceLoaderLink( $sk, $name, 'styles' ); |
— | — | @@ -2333,17 +2326,11 @@ |
2334 | 2327 | foreach ( $this->getModuleScripts() as $name ) { |
2335 | 2328 | $scripts .= self::makeResourceLoaderLink( $sk, $name, 'scripts' ); |
2336 | 2329 | } |
2337 | | - } else { |
2338 | | - // Configuration |
2339 | | - $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; |
2340 | 2330 | // Messages |
2341 | | - if ( count( $this->getModuleMessages() ) ) { |
2342 | | - $scripts .= self::makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' ); |
| 2331 | + foreach ( $this->getModuleMessages() as $name ) { |
| 2332 | + $scripts .= self::makeResourceLoaderLink( $sk, $name, 'messages' ); |
2343 | 2333 | } |
2344 | | - // Modules |
2345 | | - if ( count( $this->getModules() ) ) { |
2346 | | - $scripts .= self::makeResourceLoaderLink( $sk, $this->getModules() ); |
2347 | | - } |
| 2334 | + } else { |
2348 | 2335 | // Styles |
2349 | 2336 | if ( count( $this->getModuleStyles() ) ) { |
2350 | 2337 | $scripts .= self::makeResourceLoaderLink( $sk, $this->getModuleStyles(), 'styles' ); |
— | — | @@ -2352,7 +2339,17 @@ |
2353 | 2340 | if ( count( $this->getModuleScripts() ) ) { |
2354 | 2341 | $scripts .= self::makeResourceLoaderLink( $sk, $this->getModuleScripts(), 'scripts' ); |
2355 | 2342 | } |
| 2343 | + // Messages |
| 2344 | + if ( count( $this->getModuleMessages() ) ) { |
| 2345 | + $scripts .= self::makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' ); |
| 2346 | + } |
2356 | 2347 | } |
| 2348 | + if ( $this->getModules() ) { |
| 2349 | + // Modules - let the client calculate dependencies and batch requests as it likes |
| 2350 | + $scripts .= Html::inlineScript( |
| 2351 | + 'mediaWiki.loader.load( ' . FormatJson::encode( $this->getModules() ) . ' )' |
| 2352 | + ); |
| 2353 | + } |
2357 | 2354 | // add user JS if enabled |
2358 | 2355 | if( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) { |
2359 | 2356 | $action = $wgRequest->getVal( 'action', 'view' ); |