Page MenuHomePhabricator

Reduce ResourceLoader modules used in Minerva.
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

ResourceLoader is the name for the feature that allows us to add JavaScript and CSS to a page. This task will provide an introduction to ResourceLoader and its complexities that will aid you in any change you make in future. It will also introduce you to how caching works in Wikimedia sites. The goal of this ticket is to consolidate how we load code on pages. It should have no visual changes.

Minerva has 2 modules for shipping styles - skins.minerva.base.styles, skins.minerva.mainMenu.styles and skins.minerva.content.styles that are loaded on page load and 2 modules for icons - skins.minerva.mainMenu.icons and skins.minerva.icons.wikimedia.

Every ResourceLoader module we create increases the amount of render blocking JS we ship as ResourceLoader needs to build a dependency tree of how modules relate to one another. As a result, ideally we minimize the amount of modules we ship in production.

Acceptance criteria

  • The contents of skins.minerva.base.styles and skins.minerva.mainMenu.styles are merged (as demonstrated in this patch https://gerrit.wikimedia.org/r/c/mediawiki/skins/MinervaNeue/+/1077998)
  • A new module skins.minerva.styles is the only styles module in Minerva (ignoring icons) and combines the contents of skins.minerva.base.styles and skins.minerva.mainMenu.styles
  • Newly generated HTML will add the skins.minerva.styles module.
  • For cached HTML, keep skins.minerva.base.styles and skins.minerva.mainMenu.styles but mark them as a deprecated. New HTML should not add them to the page.
  • The bundlesize definitions in bundlesize.config.json are updated
  • Merge the skins.minerva.icons.wikimedia and skins.minerva.mainMenu.icons modules.
  • Drop .minerva-icon--{name}-base20 and .minerva-icon--{name}-disabled variants since these are no longer utilized and only serve cached HTML. The change in 1078492 means this can be safely done after the 1.43.0-wmf.27 release has happened (Tuesday 22nd at earliest).
  • Run Pixel and make sure there are no visual changes with your work.
  • Drop the skins.minerva.base.styles and skins.minerva.mainMenu.styles modules. In the process reorganize the files in the resources/skins.minerva.styles folder (we should aim to merge this patch on 19th at the earliest given we know caching can be a problem for a 2 week period)

Developer notes

For cached HTML the 2 modules are retained for a week referencing the files in the new skin.minerva.styles module.

QA

We can use Pixel to test this. No need for manual testing.

Description Text

Requirement

Consolidate ResourceLoader modules in the Minerva skin to reduce complexity and improve performance without introducing visual changes.

BDD

Feature: Consolidate ResourceLoader Modules in Minerva  

  Scenario: Verify consolidated ResourceLoader modules in Minerva  
    Given the Minerva skin uses consolidated modules  
    When the page loads on mobile  
    Then the contents of skins.minerva.base.styles and skins.minerva.mainMenu.styles are combined into a single module skins.minerva.styles  
    And cached HTML retains skins.minerva.base.styles and skins.minerva.mainMenu.styles but marks them deprecated  
    And skins.minerva.icons.wikimedia and skins.minerva.mainMenu.icons are merged into one module  
    And .minerva-icon--{name}-base20 and .minerva-icon--{name}-disabled classes are removed  
    And there are no visual changes after these updates

Test Steps

Test Case 1: Verify Consolidation of ResourceLoader Modules in Minerva

  1. Visit the Pixel report for mobile skin.
  2. AC1: Confirm that there are no errors reported in the Pixel report related to this change.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change #1078492 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Drop base20 icon class suffix

https://gerrit.wikimedia.org/r/1078492

Jdlrobson lowered the priority of this task from Medium to Low.

Olga adding this as a potential onboarding task so we don't necessarily need to point it but I do want to track it.
I've asked Steph to help with scoping this.

Change #1078492 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Drop base20 icon class suffix

https://gerrit.wikimedia.org/r/1078492

I noticed that jQuery (300 KB) is still getting loaded unconditionally. What if we had it off *by default* (i.e. in safemode) and only loaded it when someone uses a script that has it as a dependency?

I noticed that jQuery (300 KB) is still getting loaded unconditionally. What if we had it off *by default* (i.e. in safemode) and only loaded it when someone uses a script that has it as a dependency?

This is unrelated to this task. jQuery despite having limited usage on mobile is a dependency of MediaWiki core. T200868 is tracking the issue you describe.

Change #1077998 abandoned by Jdlrobson:

[mediawiki/skins/MinervaNeue@master] Merge skins.minerva.mainMenu.styles with skins.minerva.base.styles

Reason:

For reference. I'll work with Loren on this one next week.

https://gerrit.wikimedia.org/r/1077998

Change #1087993 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/skins/MinervaNeue@master] wip: Create new skins.minerva.styles module

https://gerrit.wikimedia.org/r/1087993

Change #1088347 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Remove transparent PNG icon handling

https://gerrit.wikimedia.org/r/1088347

Change #1088347 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Remove transparent PNG icon handling

https://gerrit.wikimedia.org/r/1088347

Change #1087993 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Create new skins.minerva.styles module

https://gerrit.wikimedia.org/r/1087993

Jdlrobson updated the task description. (Show Details)
Jdlrobson updated the task description. (Show Details)

Change #1090523 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/skins/MinervaNeue@master] Add module to bundlesize.config

https://gerrit.wikimedia.org/r/1090523

Change #1090523 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Add module to bundlesize.config

https://gerrit.wikimedia.org/r/1090523

Change #1090558 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/skins/MinervaNeue@master] Merge Icon Style mergeIconStyleModules

https://gerrit.wikimedia.org/r/1090558

Jdlrobson changed the task status from Open to Stalled.Nov 12 2024, 10:58 PM
Jdlrobson updated the task description. (Show Details)

Change #1090558 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Merge Icon Style mergeIconStyleModules

https://gerrit.wikimedia.org/r/1090558

Marking as stalled, based on the code being merged today, the code will be in production on 21st November. Our caches tend to last up to 2 weeks, so we should merge the clean up patch ideally on the 3rd December. (which will be sprint 5).

Marking as 3 points for the remaining work after discussion async with the team and bumping up to "Medium" given that we don't want to leave it in the current state for too long.

Jdlrobson raised the priority of this task from Low to Medium.Nov 12 2024, 11:41 PM

@LMora-WMF as discussed there may be benefits of writing the follow up patch now while it's still in your memory (that would be my recommendation)

Feel free to edit the description and tick off the Pixel todo once you've managed to run it yourself!

Jdlrobson set the point value for this task to 3.Nov 14 2024, 11:36 PM
Jdlrobson moved this task from Product Backlog to Sprint Backlog on the Web-Team board.
Jdlrobson changed the task status from Stalled to Open.Wed, Nov 20, 10:16 PM
Jdlrobson moved this task from Product Backlog to Sprint Backlog on the Web-Team board.

The code is now in production so queuing this up for sprint 5.

@Jdlrobson, I don't think this is for me to QA. If it is please provide some guidance.

SToyofuku-WMF moved this task from Product Backlog to Sprint Backlog on the Web-Team board.
SToyofuku-WMF added a subscriber: Jdlrobson-WMF.

@Jdlrobson @Jdlrobson-WMF this ticket seems to be a ghost? 👻

No clue why it's not showing up on our board but that means we missed pulling it into this sprint I believe

@SToyofuku-WMF and @loren I would say this is of higher priority than T374883. The current code is in a bit of a confusing state and we should ensure it goes out in the last deploy window of the year.

Change #1100548 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/skins/MinervaNeue@master] Reduce ResourceLoader modules

https://gerrit.wikimedia.org/r/1100548

Change #1100548 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Reduce ResourceLoader modules

https://gerrit.wikimedia.org/r/1100548

Jdlrobson added a subscriber: LMora-WMF.

For QA for this one it should be sufficient to check https://pixel.wmcloud.org/reports/mobile/index.html tomorrow and confirm no errors relating to this change.

Edtadros added a subscriber: GMikesell-WMF.

Test Result - Beta

Status: ❓Need More Info
Environment: Beta
OS: macOS
Browser: Chrome
Device: MS
Emulated Device: NA

Test Artifact(s):
Test Steps

Test Case 1: Verify Consolidation of ResourceLoader Modules in Minerva

  1. Open the Pixel report for mobile skin.
  2. AC1: Confirm that there are no errors reported in the Pixel report related to this change.

There are 5 errors, but I'm not sure if they are related to this task/patch.

pixel.wmcloud.org_reports_mobile_index.html.png (4×2 px, 1 MB)

Those changes seem unrelated so this is a pass, but have been flagged with the editing team.