This is an internal script automatically loaded by Skin.php to activate the 'jquery.hidpi' polyfill for all images on the current page in browsers that don't natively support the 'srcset' attribute on the HTML img element. This script is loaded via ResourceLoader for which Grade A currently requires: > IE11+/Edge, Chr 65+, Ff 52+, Saf 5+, Op 15+, iOS 6+, Android 4+. According to MDN and CanIUse, the basic 'x' syntax of srcset is supported, and enabled by default, in: > Edge, Chr 34+, Ff 38+, Saf 7+, Op 21+, iOS 8+, Android 5+. This means in the following browsers, MediaWiki will no longer attempt to replace images in articles with their hidpi versions. | Browser | analytics.wikimedia.org (22 May - 22 June) | ---------------------- | ----------------------- | IE 11 on Windows <= 7 | 3.4% (OS does not support HiDPI) | IE 11 on Windows 8+ | 1.1% | Safari 5 & 6 (desktop) | <0.1% | Opera 15-20 (desktop) | <0.1% | iOS 6 & 7 (mobile) | 0.1% | Android 4 (mobile) | 0.5% While the total of 1.7% is higher than our usual point where we decide to remove support, I think we should consider dropping the hidpi polyfill still for several reasons: * MobileFrontend no longer uses 'srcset' attributes. As such, these browsers don't actually change their behaviour based on the polyfill. * For IE 11/Win8 in particular, most users don't have an HiDPI monitor, but we still download the polyfill. HiDPI on Win8 is primarily tablets. * In all cases where the polyfill activates, we download the HiDPI images in addition to the standard resolution (which downloads and renders first). This is because client-side JavaScript is not able to replace it sooner. This could be considered a waste of bandwidth, as it can double or tripple the bandwidth cost for end users. This also means pages complete their loading much later because the browser first renders the page nearly to completion with standard resolution images, and only at the end our polyfill activates to restarts all image loading. The experience gracefully falls back to normal web rendering, where the standard resolution of the image is used. This would match what users of these devices see on other websites, given client-side emulation of srcset is fairly rare. == Modules The 'mediawiki.hidpi' module was removed, and considered internal to Skin.php. It contained no public methods. I confirmed there were no matches in Codesearch, and no matches in mwgrep on Wikimedia wikis. I did not remove 'jquery.hidpi', which is what contains the actual polyfill and the jQuery.fn.hidpi() public method. (Codesearch shows 2 extenisons using it, and mwgrep returned 1 unused gadget on Meta-Wiki referencing it). It has been kept, but marked as deprecated. To be removed in a future release. Bug: T127328 Change-Id: I42ce0feea1fbfe534f00e05a7cd8d81df0c33d8f
124 lines
3.1 KiB
JavaScript
124 lines
3.1 KiB
JavaScript
/* eslint-env node */
|
|
|
|
module.exports = function ( grunt ) {
|
|
|
|
var wgServer = process.env.MW_SERVER,
|
|
wgScriptPath = process.env.MW_SCRIPT_PATH,
|
|
karmaProxy = {};
|
|
|
|
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
|
grunt.loadNpmTasks( 'grunt-eslint' );
|
|
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
|
grunt.loadNpmTasks( 'grunt-karma' );
|
|
grunt.loadNpmTasks( 'grunt-stylelint' );
|
|
|
|
karmaProxy[ wgScriptPath ] = {
|
|
target: wgServer + wgScriptPath,
|
|
changeOrigin: true
|
|
};
|
|
|
|
grunt.initConfig( {
|
|
eslint: {
|
|
all: [
|
|
'**/*.js',
|
|
'!docs/**',
|
|
'!node_modules/**',
|
|
'!resources/lib/**',
|
|
'!resources/src/jquery.tipsy/**',
|
|
'!resources/src/mediawiki.libs.jpegmeta/**',
|
|
// Third-party code of PHPUnit coverage report
|
|
'!tests/coverage/**',
|
|
'!vendor/**',
|
|
// Explicitly say "**/*.js" here in case of symlinks
|
|
'!extensions/**/*.js',
|
|
'!skins/**/*.js'
|
|
]
|
|
},
|
|
jsonlint: {
|
|
all: [
|
|
'**/*.json',
|
|
'!{docs/js,extensions,node_modules,skins,vendor}/**'
|
|
]
|
|
},
|
|
banana: {
|
|
options: {
|
|
disallowBlankTranslations: false
|
|
},
|
|
core: 'languages/i18n/',
|
|
api: 'includes/api/i18n/',
|
|
installer: 'includes/installer/i18n/'
|
|
},
|
|
stylelint: {
|
|
src: '{resources/src,mw-config}/**/*.{css,less}'
|
|
},
|
|
watch: {
|
|
files: [
|
|
'.{stylelintrc,eslintrc.json}',
|
|
'**/*',
|
|
'!{docs,extensions,node_modules,skins,vendor}/**'
|
|
],
|
|
tasks: 'test'
|
|
},
|
|
karma: {
|
|
options: {
|
|
proxies: karmaProxy,
|
|
files: [ {
|
|
pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
|
|
watched: false,
|
|
included: true,
|
|
served: false
|
|
} ],
|
|
logLevel: 'DEBUG',
|
|
frameworks: [ 'qunit' ],
|
|
reporters: [ 'mocha' ],
|
|
singleRun: true,
|
|
autoWatch: false,
|
|
// Some tests in extensions don't yield for more than the default 10s (T89075)
|
|
browserNoActivityTimeout: 60 * 1000,
|
|
// Karma requires Same-Origin (or CORS) by default since v1.1.1
|
|
// for better stacktraces. But we load the first request from wgServer
|
|
crossOriginAttribute: false
|
|
},
|
|
main: {
|
|
browsers: [ 'Chrome' ]
|
|
},
|
|
chromium: {
|
|
browsers: [ 'Chromium' ]
|
|
},
|
|
firefox: {
|
|
browsers: [ 'Firefox' ]
|
|
}
|
|
},
|
|
copy: {
|
|
jsduck: {
|
|
src: 'resources/**/*',
|
|
dest: 'docs/js/modules',
|
|
expand: true,
|
|
rename: function ( dest, src ) {
|
|
return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
|
|
}
|
|
}
|
|
}
|
|
} );
|
|
|
|
grunt.registerTask( 'assert-mw-env', function () {
|
|
if ( !process.env.MW_SERVER ) {
|
|
grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
|
|
'Set this like $wgServer, e.g. "http://localhost"'
|
|
);
|
|
}
|
|
if ( !process.env.MW_SCRIPT_PATH ) {
|
|
grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
|
|
'Set this like $wgScriptPath, e.g. "/w"' );
|
|
}
|
|
return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
|
|
} );
|
|
|
|
grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] );
|
|
grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
|
|
|
|
grunt.registerTask( 'test', [ 'lint' ] );
|
|
grunt.registerTask( 'default', 'test' );
|
|
};
|