Log date · Thu
How do you test javascript-obfuscator upgrades?
Test final artifact syntax, behavior and performance after upgrades. We compare two configurations with javascript-obfuscator 5.4.6.
How should you test javascript-obfuscator upgrades?
Test syntax, behavior and performance on the final artifact in each target runtime. Using 5.4.6 on our own sample, we produced a 390-byte build with control flow flattening off and a 776-byte build with it on. Both printed the same result in Node.js and retained the sample’s escape spelling.
| Question | Result |
|---|---|
| Spread and ordinary calls | Both printed A|B|C |
| in expression in a loop | Both passed syntax check and printed true |
| Escaped string | Both retained the original escapes and printed AB at runtime |
| Output size | 390 bytes versus 776 bytes |
This is a small Node.js sample with one fixed seed and input; we did not run 5.4.5, benchmark Bun, or establish correctness for all inputs. The release notes supply the upgrade context; the experiment supplies a repeatable regression check.
What the two patches fixed
On July 9, 2026, the project released 5.4.5 at 11:20 UTC and 5.4.6 at 19:59 UTC. Version 5.4.5 fixed spread arguments intermittently being dropped when a control-flow wrapper was reused (#1423), selfDefending causing a several-fold slowdown on Bun/JavaScriptCore (#1421), and dropped parentheses around an in expression in an arrow body in a for initializer that made output unparsable (#1419). [1]
Version 5.4.6 fixed Unicode and hexadecimal escapes in string literals being converted into literal characters during obfuscation, linked to #345. [2] These are correctness and performance fixes, not new protection features. A syntax check catches an unparsable artifact but cannot detect silently changed arguments, so assert actual results too.
Sample and comparison
We wrote a plain three-argument call and a spread call, defined an arrow function containing in in a for initializer, and printed a string with hexadecimal and Unicode escapes. Both generated variants disable stringArray and use seed 42. The difference is controlFlowFlattening: off in one, on with threshold 1 in the other.
function collect(a, b, c) { return [a, b, c].join('|'); }
function exercise(args) {
const direct = collect('A', 'B', 'C');
const spread = collect(...args);
const obj = { key: 1 };
for (let check = () => ('key' in obj), i = 0; i < 1; i++) {
console.log(direct, spread, check(), '\x41\u0042');
}
}
exercise(['A', 'B', 'C']);After node --check, we ran the source and both artifacts. The transcript below shows three arguments from both calls, true from the loop check, and AB as the runtime string. Both generated files also contained the original consecutive escapes. That text check and the runtime value test answer different questions.
sample.js: A|B|C A|B|C true AB
baseline.js: A|B|C A|B|C true AB
flattened.js: A|B|C A|B|C true AB 337 sample.js
390 baseline.js
776 flattened.js
1503 total
== escaped literal in generated output ==
baseline.js: original escapes present
flattened.js: original escapes presentFlattening added 386 bytes, about 99% relative to the unflattened artifact. This tiny file cannot predict a real bundle’s size and the count is not a speed measurement. A fixed seed makes this comparison easier to repeat; test the configuration and seed used for your actual release as well.
Recommendations by risk
These are engineering recommendations, not benefits measured in our experiment. Inventory enabled options first, then choose checks for your application’s interfaces and deployment environments.
| Case | Recommendation |
|---|---|
| Control flow flattening | Assert arguments, results and side effects for plain and spread calls. |
| selfDefending | Test functionality and performance on the final file; do not modify it after obfuscation. |
| Escape spelling matters | Check both output text and runtime value. |
| Multiple target runtimes | Measure startup and key operations in each environment and record a baseline. |
The project warns that changing or minifying selfDefending output afterward can trigger the defense and break the code. [3] Place obfuscation appropriately in the build pipeline and test the file that will actually ship. Also check whether source maps are public: retain a private map matched to the build for diagnosis and inspect what the release package contains.
Obfuscation changes reading effort, while the client still executes the delivered code. Do not rely on client obfuscation to keep shared privileged keys or server authorization decisions secret. Enforce authorization on a trusted server and prepare rotation for credentials already shipped.
Run checks on your own application
First save the sample above as sample.js and reproduce it locally, then check a final JavaScript file you are authorized to test. The syntax and execution commands below apply to a Node entry point; use your own harness to load the final bundle in browsers or other runtimes. Keep production credentials and user data out of test output.
javascript-obfuscator sample.js --output baseline.js --seed 42 --string-array false --control-flow-flattening false
javascript-obfuscator sample.js --output flattened.js --seed 42 --string-array false --control-flow-flattening true --control-flow-flattening-threshold 1
node --check sample.js && node sample.js
node --check baseline.js && node baseline.js
node --check flattened.js && node flattened.js
node --check path/to/your-release.js
node path/to/your-release.jsIn CI, feed the same boundary inputs to the source build and obfuscated build and compare results, errors and external side effects. Add explicit assertions for asynchronous calls, empty arguments, spread arguments and business-critical paths; comparing console output alone is insufficient. Retain the version, configuration, seed and build identifier for a failure so the team can reproduce it.
Measure performance separately on each actual target runtime. Hold the build and device conditions steady, warm up, repeat startup and critical-operation measurements, record their distribution and compare with an unobfuscated baseline. If performance regresses, change options one at a time, then verify the final package and error-reporting path. Do not treat this tiny sample’s size ratio as a performance result.
Your checklist
- Pin the version, configuration and seed and read release notes.
- Assert spread calls and critical behavior on the final artifact.
- Check string spelling and runtime values.
- Measure performance in every target runtime.
- Match private source maps to the release and inspect the package.
Primary sources
- GitHub: javascript-obfuscator release 5.4.5 · Source date 2026-07-09 · Checked 2026-10-12
- GitHub: javascript-obfuscator release 5.4.6 · Source date 2026-07-09 · Checked 2026-10-12
- javascript-obfuscator project documentation · Checked 2026-11-11