CSS tree-shaking experiment #18278
anoyomoose
started this conversation in
Show and Tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR: https://github.com/anoyomoose/q2-css-shake
An experiment in CSS tree shaking. Results (uncompressed):
Worked out-of-the-box for 3 of our own dashboard projects.
Compressed results/usefulness debatable: % improvements are the same, but we're talking 50 to 100 kB reductions on projects that load MB's of JavaScript. Still, it does work, though YMMW.
It's a Vite plugin that works by first determining which components and icons we know of, then scanning for their usages in the tree-shaken JavaScript (Vite-provided import list for components, string usage for icons). Strongly preferring not stripping over stripping to avoid removing things your project actually needs. As such, it leaves in all utility classes (which is about half of Quasar's CSS)
Beta Was this translation helpful? Give feedback.
All reactions