-
Notifications
You must be signed in to change notification settings - Fork 11
Unique class names #20
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
base: main
Are you sure you want to change the base?
Conversation
Interesting, but I don't think this is the way to go as an optimization strategy. For example I ran this to generate the shadow-cljs UI css. While the resulting file is a bit smaller before gzip, it is actually about the same after gzip. 5525 bytes before, 5573 bytes after. brotli is similar. So, we actually gained a few bytes and lost any possible debuggability. hashes in general are pretty terrible for compression, so the HTML/JS side probably looks similar when it comes to raw gzip bytes. This was using a "minified" version, so all comments were stripped. My plan for optimizing build sizes was using active class name replacements. For CLJS this can actually be done at compile time, for CLJ that would be handled by this atom. shadow-css/src/main/shadow/css.clj Lines 6 to 7 in b3c97fe
Basic idea is to generate a "manifest" when building the CSS, populate the atom with it and use the replacement names. So, basically What this enables is that actual combinations can be created and reused. Say you have Given how well the current style compresses this hasn't seemed like a high priority so far, so have not spent any time on it. I have seen other tools use this strategy, but no data on how well that actually performs. I'll think about the hashes for a while, but no promises this will be merged. What I might be open to is "finishing" the manifest generation and then let a "customizable" mechanism optimize that, so you could just generate |
No worries, @thheller. Thanks for taking the time to look at it. Out of curiosity, was there much reuse when you ran it against shadow? |
This will make class names unique according to the rules and only put them in the CSS once. To make up for losing the usefulness of having the ns line/num in the name, I've started printing them in the output which gives this sort of thing:
My concern is the use of
hash
and just how consistent it is everywhere, however, I've tested it across different architectures and clojure versions and the output seems to be the same.