views:

171

answers:

5

How can I garble javascript code before sending it to client side. I don't want to expose functionalities. The code is already compressed using jsmin.

+1  A: 

You could try some online obfuscator like this:

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

BobbyShaftoe
+3  A: 

You need an obfuscator, see this for an example.

Anyone determined enough can always reverse it though, and tools like this can help.

Paul Dixon
A: 

Search google for: Javascript obfuscator

You might add your platform to the query, as well. There are plenty of tools already out there that you can incorporate into your project.

Tex
+3  A: 

Javascript is interpreted plaintext. As such any obfuscation is a placebo at best and easily reversed.

More to the point, if you're writing enough Javascript to constitute a work valuable enough to protect, you're doing something wrong.

My Javascript these days consists of including jQuery, a handful of plug-ins and some code to activate those plug-ins and do some styling.

I have a hard time envisioning writing anything in Javascript significant enough that I'd care about protecting it, which is just as well because you can't protect it. Not really.

cletus
Well, nowadays there are lots of sites that use mostly javascript for UI and calling remote services (a la gmail) and very little static html or server-side controls. I don't think that kind of code is 'worthless'.
axel_c
Yes and if you use a UI framework (Dojo, ExtJS, Smartclient, etc) then all the value is in the framework, not your code. Your code is just boilerplate UI code. Any real magic takes place on the serverside behind the Ajax calls. You can ripoff Gmail but without the serverside what's the point?
cletus
A: 

A word of warning: most obfuscated JS on the internet is security hole exploit code. You risk being mistaken for a sploit, particularly by the more paranoid anti-virus scanners.

bobince