0

Possible Duplicate:
How can I obfuscate JavaScript?

I have been working on a web app in JavaScript. Nearing complete.

How do I protect me JavaScript code from someone copying it? I mean if you view my page source, it references the .js files and one could really steal these.

Should I be using something else? RoR?

Does Google Maps have a RoR API?

Community
  • 1
  • 1
ator
  • 272
  • 4
  • 11
  • 6
    Definitely a duplicate. No, you can't protect your Javascript. It doesn't matter what server-side code you're using. – Pointy Oct 06 '10 at 20:17
  • You can't protect Javascript for the same reason why you can't protect HTML. Obfuscation is the best you can do. – Nitrodist Oct 06 '10 at 20:23

1 Answers1

3

Your closest bet would be to use something like

People will still be able to steal and use your code though, it will just be harder to modify.

Marko
  • 71,361
  • 28
  • 124
  • 158
  • Important to note that none of these will stop someone from using that javascript. – Incognito Oct 06 '10 at 20:22
  • I'd add a caveat to this....I would say this makes it marginally *if at all* harder if the person looking knows what they're doing. – Nick Craver Oct 06 '10 at 20:31
  • Thanks @Nick, I'm not even going to bother to prove you wrong, but it can't certainly be easy to read something like: `var _0x70fa=["\x61\x73\x6B\x31","\x0A","\x4F\x4B"];var a=_0x70fa[0];function s(_0xd48bx3){alert(_0xd48bx3+_0x70fa[1]+a);} ;s(_0x70fa[2]);` though you could use another tool to convert it back to sane Javascript. – Marko Oct 06 '10 at 20:33
  • @Marko - Sure it is, paste here: http://jsbeautifier.org/ Hit beautify, instantly: `var a = 'ask1'; function s(_0xd48bx3) { alert(_0xd48bx3 + '\x0A' + a); }; s('OK');`. Wacky variable name, but hard to figure out? not really :) I didn't say no tools were involved, just that's it's trivial to "unobfuscate" the code. – Nick Craver Oct 06 '10 at 20:43
  • Amen to that @Nick. All I'm saying it adds an extra step in reading the code since it has to go through a beautifier and maybe some manual labor. Please don't reply, you're 100% right :) – Marko Oct 06 '10 at 20:46