Disclosure: I help promote MeowShield. Most JavaScript does not care what its variables are called. A small but stubborn subset does, and that subset is where renaming-based obfuscators, MeowShield included, are most likely to surprise you. Here is how to find it before your users do.
Patterns that depend on names
Search your codebase for these before you protect a module:
// 1. Function or class names used as data
logger.info(`${handler.name} finished`);
if (err.constructor.name === "QuotaError") { /* ... */ }
// 2. Building identifiers from strings
const fn = window["render" + widgetType];
// 3. Reading source text
const src = myFunction.toString();
new Function("a", "b", "return a + b");
eval(snippet);
// 4. Serialising class instances by type name
registry[instance.constructor.name] = instance;
Each of these turns an identifier into data. Any tool that renames identifiers, or changes how a function is written, can change that data.
Why this matters for MeowShield specifically
MeowShield offers a Variable Renaming setting with several styles (Normal, Hexadecimal and more exotic alphabets), and the docs recommend starting with Normal or Hexadecimal. The Low preset also keeps KeepTopVar on by default, which the docs describe as preserving top-level variable behavior for integration-sensitive runtimes. That helps with globals, but it is not a promise about every function's .name or every toString() result inside your module. Treat those as things to test, not things to assume.
Make the dependency explicit instead
The more robust fix is to stop relying on names at all:
class QuotaError extends Error {
code = "QUOTA"; // explicit, survives renaming
}
if (err.code === "QUOTA") { /* ... */ }
const renderers = { chart: renderChart, table: renderTable };
const fn = renderers[widgetType]; // lookup table, not string concat
Explicit string properties are data you control. Identifier names are not.
A short test plan
- Grep for
.name,constructor.name,toString(),new Function,evaland computed global lookups. - Add one test per hit that runs against the protected output.
- Run the protected file in the Playground first, then in your real browser and Node targets.
- If something breaks, follow the official troubleshooting advice: lower the level or disable options, then add them back one at a time.
Limits
Obfuscation raises reading cost; it does not make secrets safe or replace server-side checks. Code that depends on its own source text is also a maintenance smell independent of any tool.
You can run a sample module through the presets at MeowShield.
Top comments (0)