Dead code is code that is never executed. Dead Code Elimination removes dead code from your program resulting in a smaller program that behaves exactly the same.
// @jscrambler enable deadCodeElimination
The following example contains dead code:
while (true) {
if (key === 'up') {
shoot();
} else if (false) {
// this is unreachable code
deleteShip();
} else {
key = 'exit'
break;
// this is also unreachable code
key = 'down';
}
}
The resulting code looks like this:
while (true) {
if (key === 'up') {
shoot();
} else {
key = 'exit';
break;
}
}
Browser | Compatible Versions | Tested Versions | Notes |
---|---|---|---|
Chrome | 80+ | 80+ | |
Firefox | 90+ | 90+ | |
Internet Explorer | 8+ | 8+ | |
Microsoft Edge | 116+ | 116+ | |
Safari | 13.1+ | 13.1+ |
Example:
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "deadCodeElimination"
}
]
}