Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: Remove unused CSS #4170

Closed
rfultz opened this issue Nov 5, 2020 · 0 comments · Fixed by #4606
Closed

Optimization: Remove unused CSS #4170

rfultz opened this issue Nov 5, 2020 · 0 comments · Fixed by #4606
Assignees

Comments

@rfultz
Copy link
Contributor

rfultz commented Nov 5, 2020

Background

Looking to optimize the site's performance and that of the homepage specifically, the Lighthouse tool in Chromium browsers has made some suggestions. Some of these will have repercussions throughout the app so we're going to make them their own tickets.

Recommendation: Remove unused CSS

Remove dead rules from stylesheets and defer the loading of CSS not used for above-the-fold content to reduce unnecessary bytes consumed by network activity. details

Overview

For the homepage in particular, we're including the elections-hash.css; Is this necessary?
Would like to prune the css so we're only including what is actually being used.

Benefit (the 80 of 80/20)

Little? Likely less than its effort

Effort (the 20 of 80/20)

Minimal to extensive
We could simply remove unused script tags and leave everything else alone
and/or
We could re-structure scss/css files and/or build so each page loads exactly the CSS it needs.

Complications

  • With all the sass inheritance, we could quickly get tangled up in untangling variables, mixins, etc.
  • While untangling, we could wind up making our lives harder by duplicating code
  • With templates being shared and inherited, we should look out for removing css from one page when it's being used by another page that's using the same template—could require additional templates.
  • Will need to account for additional modules and feature-flagged features: we should make sure to include necessary css for flag-activated features but not necessarily include it when the feature isn't 'on'.
  • Could inadvertently abandon non-desktop styles

Related tickets

This was referenced Nov 5, 2020
@rfultz rfultz self-assigned this May 6, 2021
@rfultz rfultz added this to the PI 14 Innovation milestone May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant