Skip to content

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Oct 4, 2023

Summary

Replaces the banner flag image with a losslessly compressed version, and adds a new vector (SVG) version of the image.

Related issue

Continues from #4191, closed by #4792.

Related PR

Changelog PR

Problem statement

As an end-user, I expect that pages using the U.S. Web Design system load quickly, so that I don't have to wait for assets to load.

Solution

Optimizes the existing us_flag_small.png image. It was optimized using Oxipng, via Squoosh. The choice to use Oxipng was based on a desire for lossless compression, so there should be no degradation in the quality of the image. Lossy compression is possible, and would result in an even smaller file size (I was able to shrink to 168 bytes using TinyPNG), but this would have some marginal effect on the quality of the image. tl;dr "Lossless" seemed least controversial 😄

Result:

Before: 545 bytes
After: 244 bytes
Diff: -301 bytes (-55%)

This also proposes to add a hand-optimized vector version of the image, originally proposed at #4191 (comment), and adjusted for this pull request using colors from the higher-quality image added in #4792.

Why?

  • So that a project can have the option to use a vector image
  • Vector images are scalable, and could produce better image appearance at certain sizes or on specific devices
  • While the .svg is larger size uncompressed than the .png file, it is still very small (380 bytes), and would compress to the smallest possible size (195 bytes gzipped, 180 bytes brotli'd)
  • Could allow for inlining of the image in markup

Testing and review

Visually inspect the revised assets.

@thisisdano thisisdano added Role: Dev Development/engineering skills needed Role: Visual Visual design skills needed Package: Banner labels Oct 12, 2023
@thisisdano thisisdano added this to the uswds 3.7.0 milestone Oct 12, 2023
@thisisdano
Copy link
Contributor

Thanks for this. We're going to check and see if we can get it into 3.7.0, otherwise it'll probably go into the subsequent release.

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 doing this and the detailed explanation of the solution, very helpful!

Found no visual regressions in Banner component.

Local (left) | Develop (right)
image

New flag SVG is included in built dist directory. Tested with npx gulp build.

Screenshot

image

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!

  • No visual regression
  • File size noticeably smaller
  • Both images are correctly compiled into the dist directory

Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: Banner Role: Dev Development/engineering skills needed Role: Visual Visual design skills needed
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants