Reputation: 7035
Can I hide my javascript code on the client side??? Or some way make it non-readable not by users but by hackers as well??
Upvotes: 1
Views: 2032
Reputation: 19790
There is no way. It can't be encrypted because the browser has to execute it and he doesn't know how to decrypt.
Best is to minify/obfuscate (see anax) in order to let users don't bother trying to read the code. If someone wants it badly, he eventually get it. The time to do so is high, and hopefully this will dis-encourage users.
Upvotes: 1
Reputation: 4854
Well it's not a complete solution, but you could minify your javascript to make it less human readable.
Wikipedia article on minification: http://en.wikipedia.org/wiki/Minification_(programming)
Online tool to minify javascript: http://www.refresh-sf.com/yui/
Upvotes: 2
Reputation: 9372
You can go from really cheap (adding lots of CR into the start of the HTML document) to not-so-cheap tricks (Javascript minify / obfuscate), but in reality nothing will prevent a half-descent user to read your code.
Have a look at this SO question for possible ways to obfuscate your script:
How can I obfuscate (protect) JavaScript?
Upvotes: 1