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

PageSpeed Insights consider CSS not deferred #581

Open
kyrylkov opened this issue Dec 13, 2023 · 1 comment
Open

PageSpeed Insights consider CSS not deferred #581

kyrylkov opened this issue Dec 13, 2023 · 1 comment

Comments

@kyrylkov
Copy link

kyrylkov commented Dec 13, 2023

Use

<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="styles.css"></noscript>

instead of

<link rel="stylesheet" crossorigin href="styles.css" media="print" onload="this.media='all'">

per Defer non-critical CSS https://web.dev/articles/defer-non-critical-css#optimize

Because PageSpeed Insights https://pagespeed.web.dev don't consider the latter being deferred.

image

@kyrylkov kyrylkov changed the title Use <link rel="preload" as="style"> instead of <link rel="stylesheet" media="print"> Use <link rel="preload" as="style" ...> instead of <link rel="stylesheet" media="print" ...> Dec 13, 2023
@kyrylkov kyrylkov changed the title Use <link rel="preload" as="style" ...> instead of <link rel="stylesheet" media="print" ...> PageSpeed Insights complain about CSS not being deffered Dec 13, 2023
@kyrylkov kyrylkov changed the title PageSpeed Insights complain about CSS not being deffered PageSpeed Insights complain about CSS not being deferred Dec 13, 2023
@kyrylkov kyrylkov changed the title PageSpeed Insights complain about CSS not being deferred PageSpeed Insights considers CSS not being deferred Dec 13, 2023
@kyrylkov kyrylkov changed the title PageSpeed Insights considers CSS not being deferred PageSpeed Insights considers CSS not deferred Dec 13, 2023
@kyrylkov kyrylkov changed the title PageSpeed Insights considers CSS not deferred PageSpeed Insights consider CSS not deferred Dec 13, 2023
@bezoerb
Copy link
Collaborator

bezoerb commented Jan 27, 2024

you can configure inline-critical using options:

generate({
  ...
  inline: {
    strategy: 'swap
  }
});

or using the CLI:

critical my.url.com --inline-strategy=swap

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

2 participants