Documentation
/
VM Obfuscation
/

Strict Mode Compatibility

Strict Mode Compatibility

Important

VM obfuscation needs to know at compile time whether code runs in strict mode. If your code relies on strict mode behavior, you must explicitly declare it.

Why? The VM compiles your code into bytecode before execution. It needs to know the strict mode context during compilation to generate correct bytecode for strict-mode-specific behaviors (e.g., this binding, duplicate parameters, arguments object behavior).

The strictMode option controls how the obfuscator decides. With strictMode: null (default) and strictMode: false, code is treated as strict only where it declares it: an explicit 'use strict'; directive, ES module syntax, or class methods. Everything else is compiled as sloppy mode. strictMode: true treats all input as strict. Match the context the final bundle actually runs in.

File-Level Strict Mode

Add 'use strict'; at the top of your file to enable strict mode for all code:

JavaScript

Function-Level Strict Mode

Add 'use strict'; inside specific functions if only certain functions need strict mode:

JavaScript

Common issue: If your bundler or build tool adds 'use strict'; automatically (for example a bundler that wraps CommonJS or plain script sources in strict-mode output), but you obfuscate the source before bundling, the VM won't know about strict mode. Either add the directive to your source files, set strictMode: true, or obfuscate after bundling.