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

CSS Inlining #556

Closed
matthewp opened this issue Apr 14, 2023 · 4 comments
Closed

CSS Inlining #556

matthewp opened this issue Apr 14, 2023 · 4 comments

Comments

@matthewp
Copy link
Contributor

Summary

Provide a configuration option to specify inlining behavior of styles authored or imported in astro modules.

Background & Motivation

There has been a constant interest in inlining styles while still taking advantage of scoping and other processing steps since before 1.0 (see: withastro/astro#918), with many users incorrectly assuming that is:inline directive is the solution (see: withastro/astro#6388).

Simple one-page websites do not benefit from an external stylesheet, since there is no other page that could use the cached stylesheet. On the other hand, large websites are overoptimized for cacheability, since our chunking splits the styles too granularly. Case in point, Astro docs homepage has 20 linked stylesheets, 14 of them are less than 1kb (see: withastro/astro#6528).

So far we have not provided a way to allow inlining stylesheets, prompting workarounds. However, coming from other frameworks, users might expect to be able to configure this behavior.

Goals

  • Provide a way to reduce the number of HTTP requests for stylesheets.
  • Maintain current behavior when not explicitly configured.
  • Works with both server and static outputs.

Non-Goals

  • Identify "critical" CSS rules.
  • Enable a single external stylesheet.
  • Preloading.
  • Inlining of scripts
@matthewp matthewp moved this to Stage 2: Accepted Proposals, No RFC in Public Roadmap Apr 14, 2023
@matthewp matthewp moved this from Stage 2: Accepted Proposals, No RFC to Stage 3: Accepted Proposals, Has RFC in Public Roadmap Apr 14, 2023
@matthewp
Copy link
Contributor Author

RFC: #557

@jessaleks
Copy link

Hey there, great idea!

Playing devil's advocate: how will it be better/different than critters, for which there is an integration for Astro already?

@lilnasy
Copy link
Contributor

lilnasy commented Apr 25, 2023

Hey there, great idea!

Playing devil's advocate: how will it be better/different than critters, for which there is an integration for Astro already?

@jessaleks

  • fast
  • ssr

@matthewp
Copy link
Contributor Author

This RFC was merged as approved.

@github-project-automation github-project-automation bot moved this from Stage 3: Accepted Proposals, Has RFC to Planned: Astro 3.0 in Public Roadmap May 23, 2023
@matthewp matthewp moved this from Planned: Astro 3.0 to Implemented in Public Roadmap May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Implemented
Development

No branches or pull requests

3 participants