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

Inline @media print CSS shouldn't be inline anymore #123

Closed
1 of 3 tasks
danwood opened this issue Apr 3, 2021 · 2 comments
Closed
1 of 3 tasks

Inline @media print CSS shouldn't be inline anymore #123

danwood opened this issue Apr 3, 2021 · 2 comments
Milestone

Comments

@danwood
Copy link

danwood commented Apr 3, 2021

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

In version 8 of HTML5Boilerplate, the print styles are inlined using @media print with this comment above:

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   https://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

The article, from 2007, does not seem relevant anymore. Many CSS developers are taking advantage of the fact that print-media stylesheets are now loaded asynchronously. (I don't find any specification for this, but it seems to be common practice now, and I see a reference to the async nature of print style sheets at https://developer.mozilla.org/en-US/docs/Learn/Performance/CSS)

So … I think it might be a good idea to separate out the print CSS into a separate file, loaded separately and asynchronously, to allow the main.css file to be a bit smaller, which speeds up initial page load.

@roblarsen roblarsen transferred this issue from h5bp/html5-boilerplate Apr 3, 2021
@roblarsen roblarsen added this to the v3.0.0 milestone Apr 3, 2021
@coliff
Copy link
Member

coliff commented May 11, 2021

I'm not too sure about this. If the print styles were separate it'd mean a very slight increase in the number of bytes sent over HTTP (as two CSS files compress less than one combined). It also means a very slight increase in the page weight of the HTML on every page of your site (by adding <link rel="stylesheet" href="css/print.css" media="print">).

The print styles CSS in main.css is just 319 bytes (gzipped and minified) - which is tiny, it's easier and quicker to just include them in the main stylesheet.

@roblarsen
Copy link
Member

I'm going with @coliff on this one. Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants