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

3
  • 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 :) Commented Oct 22, 2012 at 10:19
  • According to stackoverflow.com/questions/194397/… , 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) Commented Oct 22, 2012 at 10:19
  • I wouldn't be using function or variable name optimisations unless you have unit tests written. Commented Oct 23, 2012 at 22:31

2 Answers 2

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.
Sign up to request clarification or add additional context in comments.

4 Comments

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 Here is the documentation of errors. Like any other advanced code manipulation, closure compiler has some restrictions to the way you should code.
hah what a surprise, the warning I get isn't even mentioned :(
@user1548054 Maybe you should have a look at this SO question.
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

3 Comments

Thanks, JSMin is dated 2003, and packer is dated 2004 are they compatible with JQuery?
this post by the originator of jQuery may lead you away from packer ejohn.org/blog/library-loading-speed Essentially The time to uncompress defeats the packing
also caching packed files is an issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.