Targeting Specific Functions
For optimal performance, VM-obfuscate only your most sensitive code using vmTargetFunctionsMode.
Watch
Obfuscator.io: Targeting Functions in VM Obfuscation (IIFE and Comment Mode)
To VM-obfuscate only the functions you mark, enable comment mode:
Comment Mode (Recommended)
Set vmTargetFunctionsMode: 'comment' to only VM-obfuscate functions decorated with a special comment. Works at any nesting level.
Perfect for protecting license checks, authentication logic, or proprietary algorithms while keeping the rest of your code performant.
The /* javascript-obfuscator:vm */ comments must still be in the code the obfuscator receives. If a compiler, bundler, or minifier runs first, configure it to keep these comments. A stripped comment means that function is not virtualized, and if no marker survives at all, the obfuscation fails with a "no functions are marked with the /* javascript-obfuscator:vm */ directive" error.
Root Mode (Default)
Only root-level functions are considered (with Async Executor on, the outermost async functions at any depth instead; the name lists below apply to those). Use vmTargetFunctions to allow-list or vmExcludeFunctions to exclude functions by name.
Names match function declarations and named function expressions only. A function assigned to a variable (const checkAuth = () => {}) has no name to match: an allow list skips it and a deny list does not exclude it. Use comment mode for those.
