Why minification will always help compression:
Take:
function (apples) {
var all_my_apples = ["another apple"];
for (var i = 0; i < apples.length; i++) {
all_my_apples.push(apples[i]);
}
return all_my_apples;
}
function (oranges) {
var some_of_my_oranges = ["another orange"];
for (var i = 0; i < oranges.length; i++) {
some_of_my_oranges.push(oranges[i]);
}
return some_of_my_oranges;
}
The total entropy in this code is reduced significantly by having different variable names. By trading in readability, the available information in the code is being reduced. Even without reducing the size of the application at all, a hypothetical JS optimizing tool could safely transform the above into.
function (apples) {
var all_my_apples = ["another apple"];
for (var i = 0; i < apples.length; i++) {
all_my_apples.push(apples[i]);
}
return all_my_apples;
}
function (apples) {
var all_my_apples = ["another orange"];
for (var i = 0; i < apples.length; i++) {
all_my_apples.push(apples[i]);
}
return all_my_apples;
}
Now, there is significantly more repetition for an optimal compression to pick up on, all_my_apples
is repeated 6 times, and every other part of the function definition is duplicated.
In essense, minification is lossy compression.