Dead Code Elimination

Potency None
Resilience High
Cost None
Tags: dead, optimization, removal, elimination

Description

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.

Code Annotation Example

// @jscrambler enable deadCodeElimination

Example

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;
  }
}

API Parameters

Example:

{
  "keys": {
    "accessKey": "XXXXXX",
    "secretKey": "YYYYYY"
  },
  "applicationId": "ZZZZZZ",
  "params": [
    {
      "name": "deadCodeElimination"
    }
  ]
}