seu
This is all great, but while the internet is filled with auto-playing videos and invokes to external scripts from google, meta, amazon and who knows where, the example on this page is about saving... 148 bytes? Does minifying CSS really make a big difference, in the end? I'm guessing that a page with a serious CSS payload (say, over 100k) already has more serious weight problem elsewhere.
replete
LightningCSS[0] is better and faster, unless something has changed.

https://lightningcss.dev/

weinzierl
Is there a tool that can remove unused CSS while considering static HTML?

What I have in mind is a tool that I throw a CSS file and a bunch of static HTML files at, it will try to apply each CSS rule to the HTML like a browser would and remove all the rules that don't apply.

I don't expect it to ascertain if a rule had visible effects. I also don't expect it to consider JavaScript. Just plain CSS and static HTML. It doesn't look to me like CSSnano or LighteningCSS could do that.

a-french-anon
Eh, even on this example, most of the gains come from simply removing the comments (something that can easily be done with `cpp -E -P <in.css >out_cpp.css` or regexps since CSS doesn't allow comment nesting) on most UNIXes.

Here's a more complete result adding brotli and the aforementioned cpp version:

  $ gdu -b *.css *.css.gz *.css.br | awk '{if (NR % 3 == 1) {ref = $1; print} else print $0, "(" $1 - ref ")"}'
  623 in.css
  197 out.css (-426)
  355 out_cpp.css (-268)
  345 in.css.gz
  185 out.css.gz (-160)
  235 out_cpp.css.gz (-110)
  284 in.css.br
  141 out.css.br (-143)
  177 out_cpp.css.br (-107)
no_wizard
cssnano has had some complicated ownership turnover[0], I'm glad to see someone took the mantle again though.

I do find that CSSO[1] with structural optimizations can be more effective still, perhaps that will be less true overtime though.

I think once lightning CSS is more stable (in particular, some bugs are addressed around ordering) it will be the clear winner in this space though.

[0]: https://github.com/cssnano/cssnano/issues/833

[1]: https://github.com/css/csso

lofaszvanitt
People need more things that can be discovered. Everyone reinvents the wheel rn.
Inviz
Why keep background-position, if background overrides it anyway?