Debug code main purpose is to help the developer doing code debugging. This can be done in many different ways, such as log statements or assertions. Debug Code Elimination removes statements and public variable declarations used to control the output of debugging messages that help on code debugging.
Notes:
// @jscrambler define debugCodeElimination {variables: [DEBUG,DEBUG_MODE]} as dce
// @jscrambler enable dce
The following example contains some debug code to be removed:
if (typeof DEBUG === 'undefined') {
DEBUG = true;
}
// code A
if (DEBUG) {
console.log('Collecting objects.');
}
// code B
DEBUG && console.log('In debugging mode.');
Adding DEBUG
to the variables list removes any statement or public variable declaration with that name, leading to:
// code A
// code B
Name | Required | Default Value | Description |
---|---|---|---|
variables | Yes | N/A | List of variables that are intended to be removed from the code. |
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": "debugCodeElimination",
"options": {
"variables": "VALUE"
}
}
]
}