"Minification" covers a range from perfectly safe to fairly aggressive. Here's where the line sits.
Safe minification โ stripping comments and whitespace
Removing only comments and unnecessary whitespace/line breaks never touches the code's execution logic, so it's always safe. Variable and function names stay intact, keeping the code somewhat readable when debugging in browser dev tools.
Aggressive minification โ shortening variable names
A dedicated tool like Terser renames local variables to single letters like a and b to squeeze out more size. This can unexpectedly break code that accesses variables by string through eval(), or that depends on specific global scope names.
Which one to use
A simple script or internal tool is fine with light stripping of whitespace and comments. A large production web bundle should use a dedicated tool like Terser with full variable-name minification, paired with a source map.