Changesets https://gerrit.wikimedia.org/r/#/c/43979/ and https://gerrit.wikimedia.org/r/#/c/44442/ introduce changes that make mobile ResourceLoader modules for SpecialPages get dynamically defined. This is neat, however the current implementation in master (https://gerrit.wikimedia.org/r/#/c/44442/) makes it so that the modules get defined on EVERY request, including API requests, which adds unnecessary overhead.
We initially attempted to have the processing happen ONLY inside of the invocation of the ResourceLoaderRegisterModules hook, which works in MobileFrontend alpha/beta, but not in production. There are a couple of reasons for this:
- The ResourceLoaderRegisterModules hook runs AFTER SkinMobile::attachAdditionalPageResources() attaches resources (when RL is not fully in use, eg in production). You can try to get around that by forcing the hook to run by calling OutputPage::getResourceLoader() in SkinMobile::attachAdditionalPageResources(), but that bumps into another problem:
- using $resourceLoader->registerModule() in an invocation of the ResourceLoaderRegisterModules hook appears to not work properly for modules that need to be loaded at the bottom of the page. I'll be filing a separate bug for that.
We should get this fixed sooner rather than later. A few options I can think of:
- Fix #2 above
- Add a hook in SkinMobile to dynamically load last-minute modules into $wgResourceModules (this is ugly, but would go away once we resolve https://bugzilla.wikimedia.org/show_bug.cgi?id=41340)