I'm looking for a free JavaScript obfuscator. Would compression be enough? What tools would you recommend? Of course, I don't need military-style obfuscation, I need a simple way to prevent kiddies from stealing my javascript by looking at the source or by using something simple such as unescape().
Thanks,
Tom
views:
1806answers:
11http://www.javascriptobfuscator.com/Default.aspx
http://ajaxian.com/archives/utility-javascript-obfuscator
Bruno Figueiredo http://www.brunofigueiredo.com
Or, you could just stop worrying about people "stealing" the source of your web page. Either you want it out there, or you don't. Why would you come to a web site that's all about helping people learn to code, to ask for help preventing people from learning from your code?
Your problem is that no matter how much you compress it or hide it, eventually the browser has to interpret it. The best you can do is renaming all variables to meaningless random vars, and removing all comments and whitespace.
A few good tools:
If you want simple obfuscation and excellent compression, I can recommend the YUI Compressor from Yahoo.
I will second the recommendation for YUI Compressor as well, works very well and can compress and obfuscate, also makes recommendations on javascript coding.
I vote for Packer as well. There are online versions, Standalone Versions, and even a Console Version that I use to Automagically pack my javascripts when I build my web apps.
Check out For those looking - http://javascript-reference.info/javascript-obfuscators-review.htm - pretty good overview of JS obfuscators
As a rule of thumb, do not use a obfuscator that uses eval since this will slow down your page, use a compressor that doesn't. This will provide obfuscation for newbies, anyone else will not be deterred by any obfuscator anyway.
Most obfuscators will create a strings representing the code in the end and then use eval, this can be undone by a simple alert statements, whats the point?
Try this, I think it's the best one: http://utenti.multimania.it/ascii2hex/