> ## Documentation Index
> Fetch the complete documentation index at: https://docs.js-confuser.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Minify

> Minifies redundant code.

* Option name: `"minify"`

* Option values: `true/false`

***

### Input / Output

This example showcases how `Minify` transforms the code. Try it out by changing the input code and see changes apply in real-time.

```js title="Input.js" lines interactive-mode="obfuscate" theme={null}
// Input.js
var { fullName } = { fullName: 'John Doe' };

console.log(fullName); // "John Doe"

// Output.js
var HtZhTw = 'John Doe';
console.log(HtZhTw);
```

***

### Minification Techniques

* Dead code elimination
* Variable grouping
* Constant folding
* Shorten literals:
* * `true` to `!0`
* * `false` to `!1`
* * `Infinity` to `1/0`
* * `undefined` to `void 0`
* Remove unused variables and functions
* Bracket to dot notation
* Remove redundant braces
* If statement to ternary operator
* Expression consolidation

***

### Usage Example

The provided code example will obfuscate the file `input.js` and write the output to a file named `output.js`.

```js title="Usage Example" lines theme={null}
import JSConfuser from "js-confuser";
import {readFileSync, writeFileSync} from "fs";

// Read input code
const sourceCode = readFileSync("input.js", "utf8");
const options = {
  target: 'browser',
  minify: true,
};

JSConfuser.obfuscate(sourceCode, options).then((result)=>{
  // Write output code
  writeFileSync("output.js", result.code);
}).catch(err=>{
  // Error occurred
  console.error(err);  
});
```

***

#### Enabled In

* [High Preset](/presets/high): Yes
* [Medium Preset](/presets/medium): Yes
* [Low Preset](/presets/low): Yes
