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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split print styles to separate stylesheet #10419

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Conversation

aduth
Copy link
Member

@aduth aduth commented Apr 12, 2024

馃洜 Summary of changes

Splits print styles to separate stylesheet, so that it's only loaded when printing.

Why?

  • Reduce size of stylesheet for users browsing the web version of the site

Performance Impact:

NODE_ENV=production yarn build:css && brotli-size app/assets/builds/application.css

Before: 18.4 kB
After: 18.3 kB
Diff: -0.1 kB (-0.5%)

馃摐 Testing Plan

Verify that print styles are preserved:

  1. Go to http://localhost:3000
  2. Press Cmd+P
  3. Observe that the preview does not include the "Submit" button

Verify that the print stylesheet is not preloaded:

  1. In a separate Terminal process, run: curl -I --silent http://localhost:3000 | grep 'link:'
  2. Verify that the output does not include print.css

changelog: Internal, Performance, Reduce size of common application stylesheet
@@ -19,7 +19,8 @@
<%= preload_link_tag font_url('public-sans/PublicSans-Bold.woff2') %>
<%= preload_link_tag font_url('public-sans/PublicSans-Regular.woff2') %>
<%= render_stylesheet_once_tags %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= stylesheet_link_tag 'application' %>
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make a difference to keep the media: 'all' or is that basically the default value?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's redundant. I couldn't find anything which explicitly states that it's the default, but this documents the distinction between print and screen, and all as matching the union. I assume we meant it as applying the same as if it weren't applied at all.

https://drafts.csswg.org/mediaqueries/#media-types

@aduth aduth merged commit 593f3a5 into main Apr 12, 2024
2 checks passed
@aduth aduth deleted the aduth-print-stylesheet branch April 12, 2024 16:40
@mitchellhenke mitchellhenke mentioned this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants