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 Critical CSS - Umbraco #194

Open
JordanSayner opened this issue Jun 20, 2023 · 2 comments
Open

Inline Critical CSS - Umbraco #194

JordanSayner opened this issue Jun 20, 2023 · 2 comments
Labels

Comments

@JordanSayner
Copy link

Hi, I'm looking at adding critical CSS into the head of my site, and load the rest later on. see https://web.dev/extract-critical-css/ for more information.

Is there a way of doing this by default, or do I need a wrapper script to take what smidge does, then read the file and extract the content and then place that on the page?

Any help would be greatly appreciated.

@chrno1209
Copy link

I am seeking for the same, wondering if Smidge can do something for this, or at least a solution to render all css content in the head tag of my site

@Shazwazza
Copy link
Owner

There's nothing built into Smidge that knows anything about Critical CSS. However, I'm sure there's a way that you could achieve this one way or another but it depends on how you want to make it work.

Would you, for example, want a particular bundle to be rendered inline in your HTML as critical CSS?

What would need to probably happen is to move all of this code in the controller:

public async Task<IActionResult> Bundle(

to a helper method that could either return a file path or file stream. Then the controller can use this method, but would mean that you could use that method directly as well and get the file stream for that bundle and render it directly into your html.

If anyone wants to give that a try and create a PR, that would be great.

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

No branches or pull requests

3 participants