Enable Popups module in mobile, use feature detection to enable

This means that users of the mobile site on a desktop browser will
now benefit from Popups.

Targets is not necessary for `ext.popups.images` as these modules are
enabled on mobile by default.

Bug: T236097
Change-Id: I401fbb522ec97fdc81259702c8283c95386531af
This commit is contained in:
jdlrobson 2020-02-11 15:55:25 +08:00 committed by Jdlrobson
parent cd1461e5ca
commit c597522b7d
2 changed files with 8 additions and 2 deletions

View file

@ -148,11 +148,13 @@
}
},
"ext.popups": {
"targets": [ "desktop", "mobile" ],
"scripts": [
"resources/ext.popups/index.js"
]
},
"ext.popups.main": {
"targets": [ "desktop", "mobile" ],
"scripts": [
"resources/dist/index.js"
],

View file

@ -1,4 +1,8 @@
// Load Popups outside the critical rendering path (T176211)
// Load Popups outside the critical rendering path (T176211) provided that touch events
// are not available in the browser. If touch events are enabled page previews will not load.
mw.requestIdleCallback( function () {
mw.loader.using( 'ext.popups.main' );
var isTouchDevice = 'ontouchstart' in document.documentElement;
if ( !isTouchDevice ) {
mw.loader.using( 'ext.popups.main' );
}
} );