Skip to content Skip to sidebar Skip to footer

How To Protect/hide Javascript Method Or Js File From User To View

How can I protect my implemented JS methods from user? So that no one could copy these methods. Normally, User can see JS methods in firebug easily. I want to hide methods in fireb

Solution 1:

There is no way to hide your code from the user. If the browser can see it, than Firebug can see it. Using a minifier/packer used to be a way to make it harder to get to the data, but sites like http://jsbeautifier.org/ have the ability to take packed code and make it pretty.

Short answer is there is no way of hiding code. If it was possible, Microsoft, Google, Yahoo, Etc would be hiding their code.

Think of JavaScript, HTML, and CSS as open source since the source code is just one click away.

Solution 2:

The only way to efficiently protect your code is to never send it to the client: Put your “secret” methods on the server and make them ajax-callable from the client.

Solution 3:

  1. try packing the code/minifiying it

google closure compiler is a good start

there is also a YUI lib that you can use and many others.

This will make your code pretty much impossible to debug in firebug.

There is no full proof way though to stop users for mucking with your code, since it does run on the client side by definition.

  1. Another thing you can do is put the methods you want to hide inside of a closure, so that the user cant simply run someMethod() from firebug and have it execute code.

Post a Comment for "How To Protect/hide Javascript Method Or Js File From User To View"