#minification

waynerad@diasp.org

Using LLMs to reverse JavaScript minification. Project Humanify is a tool to automate this process.

"Minification is a process of reducing the size of a Javascript file in order to optimize for fast network transfer."

"Most minification is lossless; There's no data lost when true is converted to its minified alternative !0."

"Some data is lost during the minification, but that data may be trivial to recreate. A good example is whitespace."

"The most important information that's lost during the minification process is the loss of variable and function names. When you run a minifier, it completely replaces all possible variable and function names to save bytes."

"Until now, there has not been any good way to reverse this process; when you rename a variable from crossProduct to a, there's not much you can do to reverse that process."

How to codify the process of renaming a function:

"1. Read the function's body,"
"2. Describe what the function does,"
"3. Try to come up with a name that fits that description."

"For a classical computer program it would be very difficult to make the leap from 'multiply b with itself' to 'squaring a number'. Fortunately recent advances in LLMs have made this leap not only possible, but almost trivial."

"Essentially the step 2. is called 'rephrasing' (or 'translating' if you consider Javascript as its own natural language), and LLMs are known to be very good at that."

"Another task where LLMs really shine is summarization, which is pretty much what we're doing in step 3. The only specialization here is that the output needs to be short enough and formatted to the camel case."

Using LLMs to reverse JavaScript variable name minification

#solidstatelife #ai #genai #llms #codingai #javascript #minification