Astro Integration for Critical package which inlines critical-path CSS into HTML and lazy loads remaining CSS which can greatly improve First Contentful Paint (FCP).
Read more about it here: Extracting Critical CSS.
npx astro add astro-critical-css
# or
yarn astro add astro-critical-css
# npm
npm install -D astro-critical-css
# yarn
yarn add -D astro-critical-css
In your astro.config.mjs
:
import criticalCSS from "astro-critical-css";
export default defineConfig({
integrations: [criticalCSS()],
});
During your build this integration will look at all the static HTML files and run it through Critical.
experimental.prerender
in your astro config.
Check out Hybrid Renderering