8
Does any compressor take care of removing the switch cases which do not get called anywhere in the application?
function execute_case(id) {
switch(id) {
case 0:
console.log("0");
break;
case 1:
console.log("1");
break;
case 2:
console.log("2");
break;
case 3:
console.log("3");
break;
default:
console.log("default");
break;
}
}
execute_case(1);
If the above is all I have, then theoretically cases 0,2,3 are dead code and will never be executed. Does any compressor have the intelligence of removing this code when minifying code?
I am taking a look at a piece of code which has over 200,000 cases in a switch statement, and hence the question.
Thanks, -Vikrant