Skip to content

Comment on Advances in Obfuscation

Comments

Side-note: obfuscating variable and method names doesn't offer that much of a size advantage, since gzip will already compress those. Most of the gains in minifying come from removing whitespace & comments, and smart code transformations.

For Google products, huge gains come from running an optimizing compilation (Closure Compiler) which dramatically rearranges Javascript the same way GCC rearranges C into assembly.

It is not always true that minifying method names is the same as gzip, as a good minifier will understand scopes and arrange many of the variables to have both the same name and smaller distances between like symbols. This shifts the frequency distribution of the symbols as well as the distances allowing the huffman coding to be more optimal.

The Closure Compiler on ADVANCED_OPTIMIZATIONS mode is a terrifying beast and only works on carefully-crafted code. It makes some astonishing optimizations, though.

I encourage JS developers who strongly believe in distributing source along with their webapps to use source maps instead of delivering slow, unminified code. They are only downloaded when a user opens the web inspector (no overhead for regular users) and provide transparent access to source as if it had been delivered instead.

Actually it does sort of help. It allows all locals across the program to have the exact same name, which compresses much better than only some locals sharing names.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.