OutputPage: Load html5shiv without indirection of load.php
This library was introduced in3a30e03645, to make sure Grade C stylesheets that apply to HTML5 elements that older browsers might not know yet, work as expected in old IE. It originally committed a minified version and loaded it directly as an HTML script tag in a conditional comment. This had minimal impact on anything else, and was easy to maintain. In68237fb1a7, this was changed to commit the unminified version instead because Debian maintainers don't like packaging software that contain minified files, despite being a simple file, unmodified from the original (upstream publishes it in minified form, with license header), published under a compatible free license, and embedded in a license-compliant manner. We then registered it as an unused ResourceLoader module, to be minified on-the-fly at run-time. Support for "server-registered client-unregistered" modules was removed last week inc554ee8e64because nothing needed it anymore (except html5shiv apparently), which resulted in this module being registered client-side on all page views for all users (in latest master). This doesn't break anything, but it is a regression performance-wise. Restore this by (mostly) going to how it was before: A simple static file, committed to Git, served as-is. Not related to, served by, pulled through, nor registered with, ResourceLoader in any way. Only difference with the original approach is that it is no longer minified, which means a few more bytes transferred on old IE page views, which is considered an acceptable compromise. Bug: T201483 Change-Id: Ib0020b6bd015679b61f63eaa8109ed9b83d8ad15
This commit is contained in:
parent
e2e2eb49d6
commit
66a011797d
2 changed files with 10 additions and 19 deletions
|
|
@ -3012,6 +3012,7 @@ class OutputPage extends ContextSource {
|
|||
* @return string The doctype, opening "<html>", and head element.
|
||||
*/
|
||||
public function headElement( Skin $sk, $includeStyle = true ) {
|
||||
$config = $this->getConfig();
|
||||
$userdir = $this->getLanguage()->getDir();
|
||||
$sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir();
|
||||
|
||||
|
|
@ -3026,7 +3027,7 @@ class OutputPage extends ContextSource {
|
|||
$this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() )->inContentLanguage() );
|
||||
}
|
||||
|
||||
if ( !Html::isXmlMimeType( $this->getConfig()->get( 'MimeType' ) ) ) {
|
||||
if ( !Html::isXmlMimeType( $config->get( 'MimeType' ) ) ) {
|
||||
// Add <meta charset="UTF-8">
|
||||
// This should be before <title> since it defines the charset used by
|
||||
// text including the text inside <title>.
|
||||
|
|
@ -3044,18 +3045,15 @@ class OutputPage extends ContextSource {
|
|||
$pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) );
|
||||
$pieces = array_merge( $pieces, array_values( $this->mHeadItems ) );
|
||||
|
||||
// This library is intended to run on older browsers that MediaWiki no longer
|
||||
// supports as Grade A. For these Grade C browsers, we provide an experience
|
||||
// using only HTML and CSS. Where standards-compliant browsers are able to style
|
||||
// unknown HTML elements without issue, old IE ignores these styles.
|
||||
// The html5shiv library fixes that.
|
||||
// Use an IE conditional comment to serve the script only to old IE
|
||||
$shivUrl = $config->get( 'ResourceBasePath' ) . '/resources/lib/html5shiv/html5shiv.js';
|
||||
$pieces[] = '<!--[if lt IE 9]>' .
|
||||
ResourceLoaderClientHtml::makeLoad(
|
||||
new ResourceLoaderContext(
|
||||
$this->getResourceLoader(),
|
||||
new FauxRequest( [] )
|
||||
),
|
||||
[ 'html5shiv' ],
|
||||
ResourceLoaderModule::TYPE_SCRIPTS,
|
||||
[ 'raw' => '1', 'sync' => '1' ],
|
||||
$this->getCSPNonce()
|
||||
) .
|
||||
Html::linkedScript( $shivUrl, $this->getCSPNonce() ) .
|
||||
'<![endif]-->';
|
||||
|
||||
$pieces[] = Html::closeElement( 'head' );
|
||||
|
|
|
|||
|
|
@ -2820,14 +2820,7 @@ return [
|
|||
],
|
||||
],
|
||||
|
||||
/**
|
||||
* html5shiv
|
||||
*
|
||||
* This library is intended to run on older browsers
|
||||
* that MediaWiki no longer supports as Grade A, and
|
||||
* is not loaded through the normal module loading
|
||||
* system.
|
||||
*/
|
||||
// @todo FIXME: Remove 7 days after Ib0020b6bd0156 is deployed to all wikis.
|
||||
'html5shiv' => [
|
||||
'scripts' => [
|
||||
'resources/lib/html5shiv/html5shiv.js'
|
||||
|
|
|
|||
Loading…
Reference in a new issue