Live data from Hacker News

JavaScript Obfuscation Techniques by Example

trickster.dev

1–10 of 75 posts

Re: JavaScript Obfuscation Techniques by Example

#2
For mangling, I made a proxy that creates meaningful names in dev, and sequential or pre-baked ones in production.

For example, FileFields.js:

    const FF = proxyFieldNames('FF', { foo: null, bar: null })
    // DEV:  FF.foo → FF_foo
    // PROD: FF.foo → 'a'
https://github.com/uxtely/js-utils/tree/main/proxy-fields-ob...

As a bonus, it's helpful for renaming, autocompleting, and finding usages.

Re: JavaScript Obfuscation Techniques by Example

#5
post #3

Why obfuscating JS when there is WASM?

Business people demand it to protect intellectual property without realizing the ease of reversing it / wanting to say they're doing something to protect IP that their own superior will not realize doesn't help. It is making the best of an impossible situation, the paradox of sending your code to every single customer for them to run it while also wishing nobody could see it.

The more aggressive they make patent law the less useful it seems to become for protecting any actual investment, so here we are, clinging to wooden totems...

Re: JavaScript Obfuscation Techniques by Example

#6
post #4

Why obfuscate, when you can just follow modern trends and use webpack (or similar) which gives you completely unreadable shit.

I certainly agree with your tone/sympathize with your frustration but I will say that on several occasions I have followed the webpack breadcrumbs to figure out what the hell is going on with a vendor's misbehaving script, knowing it's going to be faster than going through support. Some of these methods would make that much harder.

Re: JavaScript Obfuscation Techniques by Example

#7
post #4

Why obfuscate, when you can just follow modern trends and use webpack (or similar) which gives you completely unreadable shit.

"Modern"? Webpack/code bundlers is quite an ancient tech by now.

Regard it as an intermediate representation (IR) of your code, a stage between your readable source code and browser bytecode/jit.

The "shit" is still readable since webpack also generates source maps.

Post reply on HN