Trace a compact script back to its original lines
Admin ·
When several source lines become one line, the original location is hard to infer by eye. A source map records generated positions alongside their original locations.
Generate a script and map together
Enter function double(n) { return n * 2; } on line one and console.log(double(3)); on line two. Enable Generate a source map and select Minify JavaScript. Download both outputs. The script ends with a reference to minified.js.map.
Inspect the map before sharing it
Open the map as text. Its sources array names input.js and mappings records the positions. Enable Include original source in map and repeat. The sourcesContent array now holds the entered script, including its original line breaks.
Keep a map paired with its own build
Minify a small script, store its map beside the output, then change a line in the source and repeat. Treat the two files from the second run as a pair. A map from the first output can point to a plausible but incorrect original line.
Before publishing the map, inspect its sources and any embedded source text. Share it only with the audience intended to see those files. Public availability of the minified script alone does not settle that decision.
Common questions
Can I keep readable identifiers?
The minifier keeps mangling disabled. With optimization enabled, unused bindings can disappear and expressions can be simplified.
What happens to comments?
The printer removes ordinary comments and retains recognized license or preservation comments. Keep an original copy for maintenance.