Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:JavaScript minifier name mangling

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

What Terser and esbuild rename when they minify JavaScript, how their short names are generated, and what always survives, so you know which names to trust in a minified bundle.

Terser (BSD-2)

lib/scope.js: local variables, function parameters and (with toplevel, which module mode turns on) top-level names are renamed. Options seen in the source: keep_fnames, keep_classnames, reserved (names never used or replaced), toplevel. Scopes that contain a direct eval call or a with statement are not mangled (the scope records uses_with and checks name == "eval"). Property names are only touched by the separate property mangler (lib/propmangle.js: builtins false by default so DOM and built-in names are left alone; keep_quoted leaves quoted keys), which is off by default.

Name generator base54: the first character comes from abc...zABC...Z$_ (54 letters), later ones also from digits (64); characters are sorted by how often they occur in the code (consider / sort), so the commonest letters become the shortest names. Names therefore differ between builds and between versions.

Page for the tool and its options: Tool:Terser.

esbuild

See Tool:esbuild: sequential names over a-zA-Z_$, properties kept unless --mangle-props.

What survives (practical)

  • Property and method names, object keys, string literals, template text, regexes.
  • Exported names of ES modules and webpack export maps (Tool:webpack).
  • Names under keep_fnames / --keep-names (function .name is observable).
  • Top-level names in classic scripts (not mangled unless toplevel).
  • /*! ... */ and @license comments.
  • Anything referenced by string (reflection, window["name"]).

Recovering original local names needs a source map (Format:Source map (v3), names array) or manual renaming; deobfuscation heuristics are Unverified guesses. Do not confuse with intentional obfuscation: Technique:Recognizing code obfuscation/JavaScript obfuscator output.

See Technique:Reversing bundled JavaScript.

Code & repositories