Fork me on GitHub
#clojurescript
<
2024-07-01
>
Ernesto Garcia14:07:37

Hi. Is there a way to compile using Google Closure Advanced Optimizations, but turning off property and variable renaming?

thheller14:07:04

shadow-cljs has options for this, but IIRC turning that all of disables a couple :advanced optimizations as well

Ernesto Garcia16:07:12

I'm interested in comparing gzipped sizes of renamed vs unrenamed modules with advanced optimizations on, the hypothesis being that gzip could already be doing a good job in shortening names. I've seen the VARIABLE_RENAMING and PROPERTY_RENAMING params in the Closure Compiler source code, but I'm not sure how to make use of those, especially through ClojureScript. > :pseudo-names true makes it easier to relate advanced output to what CLJS generated Maybe this could help making an assessment, thanks. @U050B88UR

Ernesto Garcia16:07:20

shadow-cljs has options for thisYou mean the :compiler-options, or others? I haven't found those in the Shadow-cljs manual.

thheller17:07:11

:compiler-options {:variable-renaming false :property-renaming false}

Ernesto Garcia17:07:20

Thanks! I'll try those out

thheller17:07:26

if you want this for debugging use shadow-cljs release app --pseudo-names. pseudo names still renames everything, but makes names somewhat recognizable. as david suggested, as a debugging aid that is useful.

👍 1
gratitude-gracias 1
thheller17:07:05

FWIW I did similar experiments a while back and gzip helps but doesn't cover enough

thheller17:07:06

for example closure will turn most function signatures into similar structures, so all function become function(a,b,c) or similar. that gzips much much better than just function(foo, bar, whatever) where the names vary from function to function

Ernesto Garcia17:07:41

I see, that's smart

thheller17:07:44

so variable renaming is definitely a must

thheller17:07:27

there is some really smart stuff in the naming strategies used, pretty much often picked with gzip in mind

thheller17:07:29

there were some really old blog posts about what they did and why, but I can't find them anymore

Ernesto Garcia07:07:11

Yeah it seems that variable renaming is the most significant part. The gain from property renaming in the case I have at hand is small (difference of 0,5 MB; 30 kB gzipped).

thheller08:07:24

yeah variable naming is the big one

thheller08:07:54

IIRC property naming could vary greatly between builds, but it has been many years so can't quite remember details

dnolen14:07:41

@titogarcia :pseudo-names true makes it easier to relate advanced output to what CLJS generated