Topic on User talk:Jdlrobson

Jump to navigation Jump to search

Using ResourceLoader's target option outside of MobileFrontend

FreedomFighterSparrow (talkcontribs)

Hi Jon,

A not-so quick question for you:

I use custom responsive skin on my wiki, but recently have started a move to separate the mobile site from the desktop one, in order to improve performance. However, I have no wish to use MobileFrontend, as it is inextricably tied to Minerva. What I did instead was take Extension:MobileDetect and improve upon it, mainly by taking parts out of MobileFrontend.

My main problem at this point is with the ResourceLoader target; I want to use that functionality to prevent some modules from loading in mobile. Unfortunately, the target definition for each module is in core, even though MobileFrontend is a separate extension - therefore certain modules that I need, such as mediawiki.legacy.shared, are not defined for mobile, simply because Minerva doesn't need them. While I can redefine every module manually for mobile, this will be very error prone; therfore, I tried doing so automatically using a whitelist and parsing both $wgResourceModules and Resources.php (because core modules aren't in $wgResourceModules).

What I do is allow 2 ways to define whitelisted mobile modules:

  1. Using the global $wgMobileDetectModuleWhitelist
  2. By a new hook, MobileDetectWhitelistModules, where you can add the name of a module(s).

This is my fork of MobileDetect, and this is a comparison showing only the whitelist changes.

Unfortunately, this just doesn't work... Maybe because I'm doing all the work in onBeforePageDisplay, and it's just too late to register and load my modules? Any ideas how to fix that? Or maybe just tell me if I'm just going down the wrong path?



P.S. I did take a look at [[ResourceLoader/Writing a MobileFrontend friendly ResourceLoader module]]. It looks like maybe your are adding modules in SkinTemplateOutputPageBeforeExec?

Jdlrobson (talkcontribs)

Minerva is not inextricably tied to MobileFrontend :) The config variable MFDefaultSkinClass is designed to allow you to choose another skin as the Mobile skin.

e.g. wgMFDefaultSkinClass = "Vector"

Jdlrobson (talkcontribs)

Once you are doing the above only 'mobile' target modules will be loaded by that skin... which I think is the behaviour you want?

FreedomFighterSparrow (talkcontribs)

Hi Jon,

I'll actually give wgMFDefaultSkinClass a go, though I fear MobileFrontend is doing way too much for what I need.

About the mobile target: the problem is that some modules, both in core (mediawiki.legacy.shared) and in extensions (CategoryTree) are not marked for mobile, because MobileFrontend/Minerva doesn't need them; however, my skin does need them. I'm trying to allow for a simple way to mark those as 'allowed on mobile', but for some reason I'm completely failing...

(Thank you for replying!)

Jdlrobson (talkcontribs)

@FreedomFighterSparrow I think the only way to circumvent this is to update the definitions in core unfortunately. I'm not sure if it's possible to do that in a hook. If possible I'd suggest migrating away from those while it's impacting you.

I don't know much about the CategoryTree extension but I suspect there is little harm in updating the module definitions there.

mediawiki.legacy.shared will be a little trickier, but it's quite a simple module and I think it would probably be easier to pick out the bits you need from it.

Jdlrobson (talkcontribs)

And on subject of MobileFrontend - we recognise this and are trying to cut it down. Pulling out the Minerva skin would reduce most of it - - I'm interested to hear how you get on with MFDefaultSkinClass!

FreedomFighterSparrow (talkcontribs)

Hi Jon, thanks for looking at this. I hate patching core - it just takes a one-time mistake when upgrading to have "unexplainable" regressions... but I'd just might do it, as I've exhausted most of my other options.

Regarding the split of MobileFrontend, I know you're working towards this and I appreciate this - we actually discussed this way back in Lyon ;-)

What's left in MF after removing Minerva?

Jdlrobson (talkcontribs)

MobileFrontend without Minerva would essentially be an extension that allows you to serve a different skin to mobile users on a different mobile domain if wanted.

There are other things it would provide under the hood:

  • mobile formatted content to support section collapsing, lazy loaded images, the ability to remove content from the mobile view, main page special casing + API to provide it.
  • various mobile optimised pages where changes to desktop have proved tricky/impossible e.g. the history, diff, watchlist pages. [note: I'd love to see these in core, but it's just not possible without HTML markup changes which will result in visible styling changes]
  • Ability to serve manifests to skins.
  • Possibly some JS friendly modules that can be used by skins that are not yet covered by core /oojs ui.
FreedomFighterSparrow (talkcontribs)

Hmmm, so basically a souped-up version of MobileDetect as I envision it. Cool :-)

Reply to "Using ResourceLoader's target option outside of MobileFrontend"