Page MenuHomePhabricator

[Spike] Review modern Vector CSS/Less before deploying everywhere
Closed, ResolvedPublic5 Estimated Story PointsSpike

Description

Vector 2022, even without icons is 3kb more of CSS than old Vector. More CSS usually results in increased time to first paint (when reader actually sees something). I suspect a lot of this relates to all the feature flags and different variants of the skin we have.

Given we are ramping up to deployment, I think a performance review (either with performance team or without) is going to be a requirement before enabling everywhere.

Questions to answer

  • How many bytes of CSS will be freed up by removal of a each of our feature flags. (described in #4)
  • How many bytes of CSS will be freed up by removal of A/B test code
  • How many bytes of CSS will be freed up by removal of legacy table of contents CSS code? Remove tablet specific styles for collapsed TOC, and misc CSS clean up 0.5kb
  • Any CSS that is outdated due to changed browser support requirements? (described in #3)
  • How much of our CSS could be scoped to logged in users only?
  • How much of our CSS could be scoped to JavaScript modules?
  • Is there anything that can be upstream to ResourceLoaderSkinModule to reduce overrides?

CSS Audit

The easiest way to compare legacy vs new Vector CSS is on a per module basis. Uncompressed, Vector 2022 styles are 23.45 kB larger than legacy (a 76.5% increase). After compression however, the difference is only 3.47 kB (still a 49% increase, but a relatively small number of bytes).

Vector ResourceLoader ModuleUncompressedGzipped
skins.vector.styles.legacy30.64 kB7.04 kB
skins.vector.styles54.09 kB10.51 kB
skins.vector.icons.js2.62 kB0.31 kB
skins.vector.icons13.41 kB0.75 kB

[x] 1.Code marked for deletion

There's at least a dozen markers in the code related to either feature-flagging, AB tests, or caching, via this codesearch query. Most seem related to the VectorTitleAboveTabs feature, but there are usages of .vector-layout-legacy which relate to the CSS Grid layout as well. Removing this code could save us some bytes (how many? well... we'll see after we remove them).

Commentlocation
FIXME: For cached CSS. can be dropped to legacy stylesheet when Ia261ea53931217f32a21b33c2ab3d4ec64efa48a has been in production for a week."MenuDropdown.less#103
FIXME: This can be merged with the above when cached HTML contains the vector-article-toolbar class.ArticleToolbar.less#33
Currently when right navigation is empty and sidebar is open no border is shown. This can intentionally be removed at a later date but is preserved to reduce number of UI regressions in current release."ArticleToolbar.less#66
TODO: #p-lang-btn Can be removed after Iebacb6a7bf3412a6ee76eb5c9fdb9471c02dd16c has been in prod for 5 days.LanguageButton.less#5
FIXME: Can be removed when "VectorTitleAboveTabs" is enabled and old layout is removed.Sidebar.less#31
T300975 following media query for TOC experiment treatment class can be removed once associated A/B test is over.TableOfContents.less#144
FIXME: The following selector can be removed when the option to disable VectorTitleAboveTabs is removed.screen.less#337
FIXME: The following selector can be removed when the option to disable VectorTitleAboveTabs is removed. screen.less#350
FIXME: The following selector can be removed when the option to disable VectorTitleAboveTabs is removed.screen.less#357
FIXME: The following selector can be removed when the option to disable VectorTitleAboveTabs is removed.screen.less#396
FIXME: The following selector can be removed when the option to disable VectorTitleAboveTabs is removed.screen.less#399
FIXME: This can be considered for removal in future or can be repurposed as a skin variable when modern and legacy Vector use different skin keys.skin-legacy.less#22

[] 2. Duplicative rules in skins.vector.styles

Using a CSS analyser like Wallace, we can see if there are any properties that could be consolidated. Using the skins.vector.styles module on beta as input, reveals that there are probably some colors that could be combined, and the amount of font-sizes we use can be reduced.

Screen Shot 2022-06-23 at 11.28.28 AM.png (602×965 px, 88 KB)

There is duplication around the black and white color values (#fff, #ffffff, #ffffff7, #000, #000000) as well as some others like blue and red. There are also lots of light-grey colors that could be consolidated.

Screen Shot 2022-06-23 at 11.28.45 AM.png (269×937 px, 49 KB)

27 unique font sizes. 6 for print, 21 for screen.

[x] 3. Removing Browser specific hacks

https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/815752

[x] 4. Removing feature flags

[x] 4. Consolidation of components

Chevrons: There are 4 unique chevron implementations in new Vector that could be consolidated.

chevron-languages.png (887×1 px, 639 KB)
chevron-more.png (1×2 px, 1 MB)
chevron-user.png (1×2 px, 1 MB)
chevron-sticky-header-languages.png (887×1 px, 787 KB)
Language menu"more" menuUser menu (reused in sticky header)sticky header language menu

Dropdowns Dropdown styles can be consolidated for various menus

Screen Shot 2022-07-27 at 1.49.27 PM.png (451×1 px, 53 KB)

Tabs The tabs in Vector need to accommodate different HTML because some are dropdowns, others are links, or icons,

https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/815323

5. Reducing layout code by adopting CSS Grid

Conclusions

As of this writing, the size of the skins.vector.styles modules in Vector has been reduced by 8.2kB uncompressed, or 1kB after gzipped. This is significant as this code is loaded on every pageload and is render-blocking.

Vector ResourceLoader ModuleUncompressedGzipped
skins.vector.styles.legacy30.59477.13965
skins.vector.styles45.89849.53418
skins.vector.icons.js7.136720.481445
skins.vector.icons13.41410.750977

Measurements were run using this gist and comparing the module size before and after various commits.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Jdlrobson added a project: Vector 2022.
Jdlrobson added a subscriber: ovasileva.

@ovasileva FYI this will be a strong blocker for enabling everywhere.

Added T306488 as subtask, although it seems better to have the tasks, given their large scope just mentioned here in relation.
T308351: Replace and remove deprecated `.transition()` Less mixin calls with unprefixed `transition` CSS property is another one.

Given we calculate these bundles with gzip, this is unlikely to make much of a difference (since it's removing repeated strings).

You were talking about bytes in the task description and the vendor prefixes are unique and unnecessary bytes shipped. :P
Gzipping's positive impact on repeated strings is true for pretty much all of CSS rules saving mentioned. So I don't see it as black/white, only as let's save what we can.

Jdlrobson renamed this task from Review modern Vector CSS before deploying everywhere to [Spike] Review modern Vector CSS before deploying everywhere.Jun 6 2022, 9:12 PM
Jdlrobson added a project: Spike.
Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptJun 6 2022, 9:12 PM

Change 810968 had a related patch set uploaded (by Jdrewniak; author: Jdrewniak):

[mediawiki/skins/Vector@master] Refactor Vector tabs layout for reduced size & complexity

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

Change 811734 had a related patch set uploaded (by Jdrewniak; author: Jdlrobson):

[mediawiki/skins/Vector@master] CSS cleanup: Revise CSS that is no longer needed per FIXME guidelines

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

Change 811734 merged by jenkins-bot:

[mediawiki/skins/Vector@master] CSS cleanup: Revise CSS that is no longer needed per FIXME guidelines

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

Change 813904 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] styles: Remove obsolete variable

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

Change 813904 merged by jenkins-bot:

[mediawiki/skins/Vector@master] styles: Remove obsolete variable

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

Change 814234 had a related patch set uploaded (by Jdrewniak; author: Jdrewniak):

[mediawiki/skins/Vector@master] [WIP] Refactor chevron implementation across components

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

Change 810968 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Refactor Vector tabs layout for reduced size & complexity

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

Volker_E renamed this task from [Spike] Review modern Vector CSS before deploying everywhere to [Spike] Review modern Vector CSS/Less before deploying everywhere.Jul 19 2022, 12:23 PM

Change 815255 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] styles: Remove divider image fallbacks for now non-basic support browsers

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

Change 815323 had a related patch set uploaded (by Jdrewniak; author: Jdrewniak):

[mediawiki/skins/Vector@master] Refactor Vector tabs layout for reduced size & complexity

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

Change 815323 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Refactor Vector tabs layout for reduced size & complexity

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

Change 815255 merged by jenkins-bot:

[mediawiki/skins/Vector@master] styles: Remove divider image fallbacks for now non-basic support browsers

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

Change 815752 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] styles: Remove IE9 Flexbox fallback

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

Change 815752 merged by jenkins-bot:

[mediawiki/skins/Vector@master] styles: Remove IE9 Flexbox fallback

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

Change 815805 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] styles: Remove `linear-gradient` hack for non-supported browsers

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

Change 815806 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] styles: Replace IE hack `list-style: none none`

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

Change 815806 merged by jenkins-bot:

[mediawiki/skins/Vector@master] styles: Replace IE hack `list-style: none none`

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

Change 815805 merged by jenkins-bot:

[mediawiki/skins/Vector@master] styles: Remove `linear-gradient` hack for non-supported browsers

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

Change 814234 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Refactor chevron across components + separate watchstar

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

Change 816788 had a related patch set uploaded (by Jdrewniak; author: Jdrewniak):

[mediawiki/skins/Vector@master] Unify dropdown styles

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

Change 816788 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Unify dropdown styles

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

Jdlrobson lowered the priority of this task from High to Medium.Sep 6 2022, 5:27 PM
LGoto added a subscriber: Jdrewniak.
ovasileva raised the priority of this task from Medium to High.Sep 13 2022, 12:40 PM
nray reassigned this task from nray to Jdrewniak.

Great work @Jdrewniak !