Skip to content

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Oct 12, 2023

Summary

Update normalize styles to remove outdated normalizations. Reduces the compiled size of normalization styles.

Related issue

Closes #4701

Problem statement

As a developer, I expect that USWDS applies its stated browser support to source code, so that I'm not misled by unexpected behaviors, or unnecessarily inflating the size of my compiled artifacts for end-users.

As an end-user, I expect that sites using USWDS load quickly, so that I'm not stuck waiting for pages to load in order to access the content I'm seeking.

Solution

The solution here refines the existing normalize stylesheet to prune styles which are not needed, either due to improvements in the affected browsers, or due to the browser no longer being supported (e.g. Internet Explorer). These refinements were applied manually, using the following projects as references:

An alternative / future-proof solution could consider incorporating something like PostCSS Normalize, which aims to automatically prune styles from the base normalization script using a project's own browserslist configuration.

@thisisdano thisisdano added Role: Dev Development/engineering skills needed Type: Enhancement and removed Status: Triage labels Nov 2, 2023
@thisisdano thisisdano added this to the uswds 3.8.0 milestone Nov 2, 2023
@mejiaj mejiaj modified the milestones: uswds 3.8.0, uswds 3.7.1 Nov 22, 2023
@amyleadem amyleadem modified the milestones: uswds 3.7.1, uswds 3.8.0 Nov 30, 2023
mejiaj
mejiaj previously approved these changes Jan 8, 2024
Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — thanks for adding the license info!

Browsers tested

  • Chromium 120
  • Firefox 122
  • Safari 17.1.2

I also created a test branch [test-aduth-modern-normalize] on uswds/uswds-site and found no issues in Accordion or Banner (tested because they rely on hidden).

This update saves 2KB on CSS, 6KB → 4KB.

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Just one question left on a changed line.

Note

I had to pull the latest changes from develop to resolve some visual discrepancies that have been previously addressed.

  • No build errors
  • No visual regressions perceived on changed elements
  • Visual display consistent across browsers

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this in Firefox, Safari, and Chromium and didn't see any regressions for the changed elements.

I wanted to flag that I found one small difference in appearance in <hr> elements in Firefox after this change, but I don't think it should be considered a blocker. I've added details in the comment below.

@mejiaj
Copy link
Contributor

mejiaj commented Mar 8, 2024

Really appreciate all the work done here.

We've put a hold on this PR for now, but we're going to look at how we can include this and other opt out features in an upcoming release.

For now, I've moved it to the 3.9.0 release milestone.

mejiaj pushed a commit to uswds/uswds-site that referenced this pull request Nov 22, 2024
Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this.

I've created a test branch on site so we can test for any regressions.

Measured the file sizes and documenting that I see the CSS is going from 677 → 676 KB.

Minor thought on giving credit in the normalize file, but don't see it as a blocker.

@@ -1,5 +1,3 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Perhaps we should give credit normalize files used here.

@thisisdano thisisdano merged commit 4218447 into uswds:develop Dec 16, 2024
5 checks passed
@aduth aduth deleted the aduth-rm-normalize-ie branch December 16, 2024 20:35
@thisisdano thisisdano mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
From: GSA Role: Dev Development/engineering skills needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace normalize with a more modern CSS reset
6 participants