Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2280,8 +2280,9 @@ |
2281 | 2281 | return $ret; |
2282 | 2282 | } |
2283 | 2283 | |
2284 | | - static function makeResourceLoaderLink( $skin, $modules, $only ) { |
2285 | | - global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug; |
| 2284 | + // TODO: Document |
| 2285 | + static function makeResourceLoaderLink( $skin, $modules, $only, $useESI = false ) { |
| 2286 | + global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug, $wgResourceLoaderUseESI; |
2286 | 2287 | // TODO: Should this be a static function of ResourceLoader instead? |
2287 | 2288 | // TODO: Divide off modules starting with "user", and add the user parameter to them |
2288 | 2289 | $query = array( |
— | — | @@ -2327,11 +2328,22 @@ |
2328 | 2329 | } |
2329 | 2330 | // Make queries uniform in order |
2330 | 2331 | ksort( $query ); |
2331 | | - // Automatically select style/script elements |
2332 | | - if ( $only === 'styles' ) { |
2333 | | - $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n"; |
| 2332 | + |
| 2333 | + $url = wfAppendQuery( $wgLoadScript, $query ); |
| 2334 | + if ( $useESI && $wgResourceLoaderUseESI ) { |
| 2335 | + $esi = Xml::element( 'esi:include', array( 'src' => $url ) ); |
| 2336 | + if ( $only == 'styles' ) { |
| 2337 | + $links .= Html::inlineStyle( $esi ); |
| 2338 | + } else { |
| 2339 | + $links .= Html::inlineScript( $esi ); |
| 2340 | + } |
2334 | 2341 | } else { |
2335 | | - $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n"; |
| 2342 | + // Automatically select style/script elements |
| 2343 | + if ( $only === 'styles' ) { |
| 2344 | + $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n"; |
| 2345 | + } else { |
| 2346 | + $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n"; |
| 2347 | + } |
2336 | 2348 | } |
2337 | 2349 | } |
2338 | 2350 | return $links; |
— | — | @@ -2348,8 +2360,8 @@ |
2349 | 2361 | function getHeadScripts( Skin $sk ) { |
2350 | 2362 | global $wgUser, $wgRequest, $wgUseSiteJs, $wgResourceLoaderDebug; |
2351 | 2363 | |
2352 | | - // Statup - this will immediately load jquery and mediawiki modules |
2353 | | - $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts' ); |
| 2364 | + // Startup - this will immediately load jquery and mediawiki modules |
| 2365 | + $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts', true ); |
2354 | 2366 | |
2355 | 2367 | // Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a |
2356 | 2368 | // whole script tag -- grumble grumble... |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1667,6 +1667,13 @@ |
1668 | 1668 | $wgResourceLoaderDebug = false; |
1669 | 1669 | |
1670 | 1670 | /** |
| 1671 | + * Enable embedding of certain resources using Edge Side Includes. This will |
| 1672 | + * improve performance but only works if there is something in front of the |
| 1673 | + * web server (e..g a Squid or Varnish server) configured to process the ESI. |
| 1674 | + */ |
| 1675 | +$wgResourceLoaderUseESI = false; |
| 1676 | + |
| 1677 | +/** |
1671 | 1678 | * Enable data URL embedding (experimental). This variable is very temporary and |
1672 | 1679 | * will be removed once we get this feature stable. |
1673 | 1680 | */ |