Page MenuHomePhabricator

Gadgets should not be loaded as module-styles by default
Closed, DuplicatePublic

Description

If a gadget has no styles it is included in the URL in the head of the document. If a skin has no top loaded styles this can result in an unnecessary HTTP request for an empty file.

Steps to demonstrate:

Note the link tag:

<link rel="stylesheet" href="/w/load.php?debug=false&amp;lang=en&amp;modules=ext.gadget.switcher%7Cext.gather.menu.icon%7Cmediawiki.raggett%7Cmediawiki.ui.button%2Cicon%7Cskins.minerva.base.reset%2Cstyles%7Cskins.minerva.content.styles%7Cskins.minerva.icons.images%7Cskins.minerva.tablet.styles&amp;only=styles&amp;skin=minerva&amp;target=mobile" />

See [[ https://en.m.wikipedia.org/w/load.php?debug=false&modules=ext.gadget.switcher | ext.gadget.switcher ]]is present.

In Vector we load the following styles for gadgets:
https://en.wikipedia.org/w/load.php?debug=false&lang=en&modules=ext.gadget.DRN-wizard%2CReferenceTooltips%2CWatchlistBase%2CWatchlistGreenIndicators%2Ccharinsert%2Cfeatured-articles-links%2CrefToolbar%2Cswitcher%2Cteahouse&only=styles&skin=vector

Issues:

  1. Many of these do not seem vital to top load
  2. Some of these e.g. https://en.wikipedia.org/w/load.php?debug=false&lang=en&modules=ext.gadget.DRN-wizard&only=styles&skin=vector have no styles despite being included in the request

Event Timeline

Jdlrobson raised the priority of this task from to Needs Triage.
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: Jdlrobson.
Legoktm claimed this task.
Legoktm added a subscriber: Legoktm.

ext.gadget.* is an on-wiki gadget from somewhere. ext.gadgets.* are modules provided by the extension.

It seems to be a global gadget then since I'm seeing it while anonymous. How is this happening and who do I talk to rectify this?

Jdlrobson set Security to None.
Jdlrobson added a subscriber: kaldari.

@kaldari any ideas?

There are no such things as global gadgets. What wiki is this on?

The switcher gadget on the English Wikipedia doesn't have any CSS, it's pure JS: https://en.wikipedia.org/wiki/MediaWiki:Gadget-switcher.js

But it shouldn't be loaded because it doesn't have targets set...hrm.

Ignore me, it does:

switcher[ResourceLoader|default|targets=desktop,mobile]|switcher.js

So is the problem that you don't want the gadget running on mobile? That seems like something to ask for on-wiki.

Er, hold on a second. That gadget doesn't have any styles. Why is it in a <link> tag?

Seems this module is working on mobile but doesn't have any associated styles so yes.. very bizarre this is in the link tag. Same for desktop site.

Jdlrobson renamed this task from ext.gadget.switcher top loaded on Minerva skin for anons despite not being used in mobile skin to Gadgets styles are top loaded (including when empty).Feb 16 2016, 10:38 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson edited projects, added Performance-Team; removed MediaWiki-ResourceLoader.
Jdlrobson updated the task description. (Show Details)

Have updated the description - it seems we include empty modules in that link tag and each gadget has a corresponding style module loaded in the head. We may want to re-evaluate this.

It's most likely in the <link> because it's added with addModuleStyles(). We currently don't distinguish style-only gadgets from regular gadgets.

For style-only gadgets, they should always be in the <link> because that tag is cached in the html for 30 days. If it's enabled site-wide it should consistency show up on pages if/when styles are added to the gadgets.

The bottom-line issue here is that gadgets are currently always loaded with addModules() and addModuleStyles() which is a RL design violation we currently tolerate. We should probably make that an option in the gadget definition (either static styles or dynamic, defaulting to dynamic module js/css).

Krinkle renamed this task from Gadgets styles are top loaded (including when empty) to Gadgets should not be loaded as module-styles by default.Feb 16 2016, 11:37 PM