Possible Duplicate:
How can I obfuscate JavaScript?
I want to “protect” my Javascript code. Are there any good, recommended ways which are very difficult to hack?
I tested some encoder on the Web and sometimes my Javascript code doesn’t work after encoding.
Is this normal (cot the encoder is very bad)?… or is my code too bad/buggy?
You can’t prevent anyone from looking at your javascript code. Its basically the same as html in that way. You can make it very difficult to decipher, aka obfuscation, but you really gain nothing from this.
If you have application critical code that for whatever reason you feel is mission critical, design your web app in such a way that the “protected” code is run on the server. Communicate to the front-end (the browsers) using xhr requests that are only passing state data back and forth.