On 01/10/10 07:27, Roan Kattouw wrote:
Minified code does not contain zero line breaks. Some line breaks are left in, although I don't understand exactly what the logic is there.
The logic is that line breaks can have functional significance in two cases. One is where statement-ending semicolons are omitted:
foo() bar()
A semicolon is implied where the result of joining the lines would not be valid JS, in this case:
foo() bar()
This is not valid so a semicolon is implicitly added. The other case is where a line break acts like whitespace:
x- -y
Here the first "-" is the subtraction operator, and the second "-" is the unary negation operator. This is the same as "x- -y" but not the same as "x--y", which is a syntax error since the "--" is counted as the unary postfix decrement operator.
Determining all of these cases precisely would be difficult, so JSMin just leaves the line break in where it follows any potentially problematic token.
-- Tim Starling