cljs-dev

dnolen 2025-08-06T11:07:00.190269Z

@thheller you mentioned some knobs in shadow-cljs for code size - I'm curious what you have and the impact?

thheller 2025-08-06T13:59:52.568749Z

the most impactful build size wise is :shadow-keywords. turns new $("shadow.cljs","init-complete?","shadow.cljs/init-complete?",-609406251); into O("shadow.cljs","init-complete?");. basically one step further for the optimize constants thing. new cljs.core.Keyword repeats the namespace string, and the hash is not very gzip friendly. impact varies greatly between build using a lot of namespaced keywords, or even just keywords. I've had reports for this shaving off between 5 and 10% of the gzip'd build size. basically just introduces a https://github.com/thheller/shadow-cljs/blob/4a20a459baf49fb1a78227a03cfe8bdac4b121d6/src/main/shadow/build/closure.clj#L683-L685 and rewrites new cljs.core.Keyword to use that instead. never could measure any difference regarding the dropped hash value, so just removed it.

thheller 2025-08-06T14:02:40.021569Z

others are more about aesthetic than about build size. defonce just turns into def for optimized builds. defonce can leave a rather nasty and long typeof chain for namespaces with many segments, which just isn't needed for optimized builds. that just annoyed me, but no measurable difference for build size really.

thheller 2025-08-06T14:03:34.985419Z

I also implemented https://ask.clojure.org/index.php/8879/cljs-should-macros-support-lifting-vars-to-the-ns-level, which shaves a bit of reify. but also not really measurable

thheller 2025-08-06T14:05:01.775459Z

I know I had some more but can't even remember what they are, but again very minor stuff

thheller 2025-08-06T14:05:24.788809Z

only thing with any impact really is the constants thing

dnolen 2025-08-06T14:21:57.835379Z

ok the constants thing is interesting - that could just be something :lite-mode does, drop the precomputed hashes

thheller 2025-08-06T14:22:41.835659Z

doubt people using :lite-mode are gonna be very keyword heavy

dnolen 2025-08-06T14:23:29.555119Z

keyword don't add that much as far as I can tell.

dnolen 2025-08-06T14:23:38.819189Z

basically all the non-collection types are not that bad.

dnolen 2025-08-06T14:23:48.574839Z

I can believe the compression problem though