I know it's not possible to encrypt JS code, but how can I make it difficult to understand for everyone, like jquery.min.js?
-
2Or google `js uglify` – Ivan Chernykh Aug 31 '13 at 12:09
-
Obfuscation using many libraries available freely. – Narendra Pathai Aug 31 '13 at 12:09
-
1`jquery.min.js` is no way difficult to understand. – bansi Aug 31 '13 at 12:11
5 Answers
There are multiple terms for this:
- Minifying, like
jsmin
- Obfuscating or uglifying, like
uglifyjs
- Packing, like
packer3
- Arguably, compressing, like YUI Compressor
- Compiling, like Google's Closure Compiler
That last is slightly different from the first four, because it will apply actual compilation algorithms and heuristics to your code. For instannce, if you have a short function, the Closure compiler might inline it (provided doing so doesn't have side-effects).

- 1,031,962
- 187
- 1,923
- 1,875
That specific file is 'minified'. This makes variable names smaller and removes whitespace to reduce the bytes required to store the file on the server, and make it quicker to download. There is an online tool you can use to do this: JSCompress
Note that this is not 'difficult to understand' to anyone who knows javascript. There may be obfuscating tools, but they are largely pointless for javascript. As with anything, if you aren't prepared to have someone see what you've created, don't put it online.

- 331,213
- 40
- 305
- 339
use http://javascriptcompressor.com/
Compress and obfuscate Javascript code online completely free using this compressor.

- 1,763
- 1
- 10
- 14
Use a code minifier like: http://jscompress.com/
There are many out there that do different kinds of obfuscation and minifications. I myself use minify for nodejs - https://npmjs.org/package/minify

- 3,508
- 25
- 27