JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)
Why do you need Obfuscation
Below are the few reasons for Obfuscation,
- The Code size will be reduced. So data transfers between server and client will be fast.
- It hides the business logic from outside world and protects the code from others
- Reverse engineering is highly difficult
- The download time will be reduced
Practical Code Example
javascript
// Obfuscation: Transforms source code into difficult-to-understand representations
// protecting proprietary IP against reverse engineering:
// Original:
function login(username, password) { return password === 'secret'; }
// Obfuscated representation:
// function _0x2a(_0x1b,_0x3c){return _0x3c===String.fromCharCode(115,101,99,114,101,116);}