Feature request: Critical CSS generation for Tailwind CSS?

Hello, dear developers.

As I know, Hugo doesn’t support Critical CSS generation during build time. But Hugo now has built-in support for Tailwind CSS.

If you are writing your CSS manually, it’s not hard to insert critical CSS manually into the <head> section of the site. But when you are using Tailwind CSS, I think it’s necessary to have built-in support on the framework level to generate Critical CSS.

Would be great, if Hugo automatically detect like the first 300 or 500 lines of the CSS code (or whatever amount you provide in the config file), and place this code within the <head> section of the site instead of building the whole CSS into one file.

What do you think about that feature? Is it possible to implement it technically? Or is there any workaround to generate critical CSS for Tailwind by yourself?

Check out this tool

Yes, I saw those tools, but you need to set up a bundler first, like gulp/webpack, which means extra complexity I’m trying to avoid.

Would be much better if Hugo had built-in support for Critical CSS generation.

It seems to me that if you’re using Tailwind and Hugo, not overusing JavaScript snippets and not loading oversized assets like videos or huge images, then your site will already be faster than 99% of websites on the internet. Why try to speed up something that’s already fast — or am I missing something? Don’t let perfect be the enemy of good.