0

Possible Duplicate:
How can I obfuscate JavaScript?

Is there any way to protect my js file or javascript function from user to view?

Community
  • 1
  • 1
  • against this being a duplicate: obfuscation is different and im not sure this questioner knows the difference. he asked how to protect it, not obfuscate. but obfuscation was given as an idea because the answer is 'there is no way to protect a javascript' – Ross Dec 28 '10 at 12:52
  • in fact, there is a way, using server side code, using a object container component (such flash, silverlight and flash) and may be other ways. – magallanes Aug 29 '11 at 17:05

3 Answers3

1

You could minify/obfuscate it but the function would still be visible to the user.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

Nope but you can always obfuscate. just look up online for javascript obfuscator. It makes code harder to read but it'll still be decodable.

If you need to hide code may I suggets something serverside such as php, aspx etc..

Ross
  • 1,013
  • 14
  • 32
0

Like Darin sayd, you can obfuscate the code. But if you want execute a js file on a browser, the user can get the source code. There is no way to avoid this.

Community
  • 1
  • 1
pythonFoo
  • 2,194
  • 3
  • 15
  • 17