6

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

Tom
  • 6,991
  • 13
  • 60
  • 78
  • 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? – Coderer Nov 07 '08 at 15:08

9 Answers9

16

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:

Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
Loki
  • 6,205
  • 4
  • 24
  • 36
  • Just like you can recognize structures and replace them as part of code optimization, you can recognize structures and replace them specifically to make code harder to follow. It tends to still be breakable, make things slower and use more ram, but companies sell tools to do it. – Louis Gerbarg Nov 07 '08 at 15:46
  • I think its not a good solution, you can deobfuscate the code with http://jsbeautifier.org/. – Afshin Mehrabani Nov 02 '12 at 04:14
5

You can use /packer/

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

Imran
  • 87,203
  • 23
  • 98
  • 131
4

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?

Alex Lehmann
  • 668
  • 1
  • 6
  • 11
3

If you want simple obfuscation and excellent compression, I can recommend the YUI Compressor from Yahoo.

Loris
  • 1,940
  • 3
  • 19
  • 27
1

Check out For those looking - http://javascript-reference.info/javascript-obfuscators-review.htm - pretty good overview of JS obfuscators

0

Try http://digua.sourceforge.net.

0

I will second the recommendation for YUI Compressor as well, works very well and can compress and obfuscate, also makes recommendations on javascript coding.

NBRed5
  • 121
  • 4
0

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.

Jeff Sheldon
  • 2,074
  • 1
  • 14
  • 23
  • maybe your answer is more about compression then obfuscation? – tomasb Jan 28 '15 at 16:45
  • My answer was a touch more relevant over 6 years ago when it was posted. Maybe not so much now. Better question is why are you commented on a 6 year old answer to a closed question? – Jeff Sheldon Jan 28 '15 at 19:12
-1

http://www.javascriptobfuscator.com/Default.aspx

http://ajaxian.com/archives/utility-javascript-obfuscator

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
Bruno Shine
  • 1,021
  • 1
  • 9
  • 17