Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load MediaWiki:Mobile.css as a render-blocking style
For consistency with MediaWiki:Common.css, which is also render-blocking. Split MediaWiki:Mobile.css off into its own module (mobile.site.styles) and load it using addModuleStyles(). The JS stays in mobile.site. Bonus: respect $wgUseSiteJs and $wgUseSiteCss. Bug: T190083 Change-Id: I404dfbc2ee377426fda8377437dcf7bb5e8a0c4f
- Loading branch information
1 parent
be82a46
commit 619fb7e
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace MobileFrontend\ResourceLoaderModules; | ||
|
||
use ResourceLoaderWikiModule; | ||
use ResourceLoaderContext; | ||
|
||
/** | ||
* Alternate of ResourceLoaderSiteStylesModule for mobile web. | ||
* Mobile.css is a temporary drop-in replacement for Common.css which contains CSS that | ||
* is usually incompatible. | ||
*/ | ||
class MobileSiteStylesModule extends ResourceLoaderWikiModule { | ||
// Should not be enabled on desktop which has ResourceLoaderSiteStylesModule instead | ||
protected $targets = [ 'mobile' ]; | ||
|
||
/** | ||
* Get a list of pages used by this module. | ||
* | ||
* @param ResourceLoaderContext $context | ||
* @return array | ||
*/ | ||
protected function getPages( ResourceLoaderContext $context ) { | ||
$pages = []; | ||
if ( $this->getConfig()->get( 'UseSiteCss' ) ) { | ||
$pages += [ | ||
'MediaWiki:Mobile.css' => [ 'type' => 'style' ], | ||
]; | ||
} | ||
return $pages; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() { | ||
return self::LOAD_STYLES; | ||
} | ||
} |