matthiasmullie / minify

CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
https://matthiasmullie.github.io/minify/
MIT License
1.96k stars 310 forks source link

Syntax error on minified JS - missing semicolon after empty for #385

Closed short-pixel-optimizer closed 2 years ago

short-pixel-optimizer commented 2 years ago

The following JS breaks after being minified:

var l = 5; var w = [1, 2]; if (l !== 3) { for (var V = w.map((function(e) { return e })).length; !(l >= V); V++); } else var C = 3;

Using latest version 1.3.66, this gets minified to:

var l=5;var w=[1,2];if(l!==3){for(var V=w.map((function(e){return e})).length;!(l>=V);V++)}else var C=3

which breaks, instead of the syntactically correct (notice the semicolon after V++) ):

var l=5;var w=[1,2];if(l!==3){for(var V=w.map((function(e){return e})).length;!(l>=V);V++);}else var C=3