- a = a + x ==> a+=x - joining consecutive var statements (hoisting is not always desirable) - x == false ==> x == 0, x != true ==> x != 1 - x, x ==> x; x = exp(), x ==> x = exp() - discarding useless break-s
80 lines
1.4 KiB
Plaintext
80 lines
1.4 KiB
Plaintext
✓ a = a + x ==> a+=x
|
|
|
|
*******
|
|
|
|
✓ join consecutive var statements
|
|
|
|
*******
|
|
✓
|
|
x == false ==> x == 0
|
|
x == true ==> x == 1
|
|
|
|
should warn too;
|
|
JS is so sloppy that this could be an indication of a bug.
|
|
|
|
*******
|
|
|
|
✓
|
|
|
|
x, x ==> x
|
|
x = foo, x ==> x
|
|
|
|
other similar cases?
|
|
|
|
*******
|
|
|
|
Try to concatenate all scripts somehow before starting minification;
|
|
the issue will be keeping track of the current source file for
|
|
generating source maps. perhaps store that in the AST? Have a single
|
|
AST_Toplevel for all files.
|
|
|
|
XXX? Not sure if this is worth the trouble.
|
|
|
|
*******
|
|
|
|
✓
|
|
|
|
discard spurious break statements
|
|
|
|
*******
|
|
|
|
for (...) {
|
|
if (foo) continue;
|
|
...
|
|
}
|
|
|
|
==>
|
|
|
|
for (...) {
|
|
if (!foo) { ... }
|
|
}
|
|
|
|
*******
|
|
|
|
The following seems to compress suboptimally. Should probably run more
|
|
passes somewhere.
|
|
|
|
function setOpacity(el, o) {
|
|
if (o != null) {
|
|
if (o == "" && o != 0) {
|
|
is_ie
|
|
? el.style.filter = ""
|
|
: el.style.opacity = "";
|
|
} else {
|
|
is_ie
|
|
? el.style.filter = "alpha(opacity=" + Math.round(o * 100) + ")"
|
|
: el.style.opacity = o;
|
|
}
|
|
return o;
|
|
} else {
|
|
if (!is_ie)
|
|
return parseFloat(el.style.opacity);
|
|
else
|
|
if (/alpha\(opacity=([0-9.])+\)/.test(el.style.opacity))
|
|
return parseFloat(RegExp.$1);
|
|
}
|
|
}
|
|
|
|
*******
|
|
|