0

what is the best JS minifier / obfuscator to use for projects that use JQuery? I'm currently using the closure compiler and I've also tried YUI but they never seem to minify and optimise my function names or variable names, effectively all they do is remove whitespace and comments whereas I'm trying to make my code as small as possible and hide as much as possible.

Any ideas?

Thanks

Tiborg
  • 2,304
  • 2
  • 26
  • 33
user1548054
  • 21
  • 1
  • 5
  • Just Google and try different ones. There's several online ones that I've used before, but I can't give you the URLs because I don't have them. I just search when I need one. Try doing the same :) – Reinstate Monica Cellio Oct 22 '12 at 10:19
  • According to http://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript , it seems you already have the best tools for the purpose... by the way, you can always use one of the web obfuscator that google can provide you (like i did at the time) – Andrea Ligios Oct 22 '12 at 10:19
  • I wouldn't be using function or variable name optimisations unless you have unit tests written. – Razor Oct 23 '12 at 22:31

2 Answers2

1

Take a look at the closure compiler again. It has 3 execution levels

  1. Whitespace only You used this setting. Just redundant whitespaces are removed.
  2. Simple In addition to removing whitespaces this renames your variables and function names to shorten the overall scripts, but leave your code intact.
  3. Advanced This further improves the simple setting by possible restructuring your code. So, e.g., some functions may get inlined etc.
Sirko
  • 72,589
  • 19
  • 149
  • 183
  • Thanks for that, I have tried this before but I get warnings on the advanced mode for things like this : JSC_INEXISTENT_PROPERTY: Property done never defined on ? at line 611 character 0 $.getScript – user1548054 Oct 22 '12 at 11:07
  • @user1548054 [Here](https://developers.google.com/closure/compiler/docs/error-ref?hl=de) is the documentation of errors. Like any other advanced code manipulation, closure compiler has some restrictions to the way you should code. – Sirko Oct 22 '12 at 11:32
  • hah what a surprise, the warning I get isn't even mentioned :( – user1548054 Oct 23 '12 at 08:05
  • @user1548054 Maybe you should have a look [at this SO question](http://stackoverflow.com/q/11178589/1169798). – Sirko Oct 23 '12 at 08:09
0

Closure is a good minifier. Also there are other minifiers worth to check,

Packer: http://dean.edwards.name/packer/

JSMin: http://crockford.com/javascript/jsmin

Muthu Kumaran
  • 17,682
  • 5
  • 47
  • 70