DEV Community

Discussion on: How to protect your JavaScript Code

Collapse
 
jayjeckel profile image
Jay Jeckel

Obfuscation is at best rude and more often it is actually harmful to your users. The example in this article perfectly demonstrates why. Look at all the useless operations that are being run in the obfuscated form of the code. Those operations are unneeded, waste your users' cpu cycles, and cost your users money in the form of more electricity for no benefit to anyone.

while (!![])

That line alone should show any developer that obfuscation is harmful. If a developer put that code in one of my codebases, I'd fire them on the spot. And it being put there by an automated process doesn't make the code smell any less.

If one absolutely has to obfuscate their code, then, please, as a developer and user, I beg of you to use an obfuscation library that doesn't add pointless code that does nothing other than waste the user's time and money.