Hi, We are building this web application that uses a good deal of Javascript code. Right now, the developers have built all the code into the HTML page, so that any one can view the source code. This is something we need to change so that the Javascript code is kept completely hidden from view. What is the best way to achieve this? Thanks.
The user's browser has to have access to the javascript inorder to process it. I dont believe there is a way to hide the code. I might be wrong however.
type this on google "javascript encryption tool" and you should find some interesting stuff. I would be interested too in some nice tools for encryption or isolation of the javascript code in a page. Good luck, if you find something interesting please let us know.
Recoding to Ajax would be ideal. If you leave it as javascript, I don't think there's any way to hide it COMPLETELY. You can however obfuscate it some, that is make it more difficult to obtain. Things like, capture mouse clicks and prevent them from right-clicking on the page. Then they do right-click-view-source in IE. Put the page in frames, so if they access view source from the view menu, they get the source of the main frame which just defines the inner frame. But then you have to prevent them from typing the url of the inner frame in and loading just that... If the user is determined, you can't stop him from getting clientside code. That's why it's clientside. That's why Everquest and World of Warcraft are still being hacked to this day, because with games that complex and that many people, there are some things you HAVE to do clientside like movement or there'd be massive lag, but by doing it clientside the user has access to it and can see things they shouldn't see. If you truly must keep it secret, converting it to server-side code is absolutely necessary. Ajax would be preferable because you wouldn't lose the functionality of not needing page reloads, but using normal asp or asp.net or php or something (making it truly server side) would be the easy way although the site would function slower as you would have more page reloads. Ajax is more complicated to convert to, but ideal.