4

I have created an application which contains java script, which i want to be secure. I know obfuscate is a good idea to secure the code.but it can easily be decoded. can any one suggest any method through which some part or whole of my java script code can be secured.

3
  • 2
    You can run your JS server side ;) Commented Feb 12, 2014 at 7:11
  • If you are running JS on the client, obfuscation is the "best" method of securing it (some people try to also sell "encryptors") - this is because the client must have access to run it. And someone who really wants to access the JS can. Commented Feb 12, 2014 at 7:11
  • 1
    Just write your code in a way that makes anyone that reads it want to kill himself. (A coding style that many people seem to use instinctively) Commented Feb 12, 2014 at 7:29

1 Answer 1

3

First minify your code, then obfuscate it, that's all you can do really.

Someone can take and run your code, but they wont be able to understand it enough to customise it because the variables and functions would be named like a, b, c if you minify it.

You could have some domain protection like if document.href === 'mysite' then run code, it wont secure it, but it's an obstacle

And you can load your scripts via Ajax, then eval it, that would mean it would be harder to find the script, the only way you could find it is if you checked the network requests.

As you can see there is no way of securing it, but you can put a load of obstacles in the way

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the rply...but it can be simply unminified using jsbeautifier.org
No it can't that's just tabs and spaces
Closure Compiler is a tool for making JavaScript download and run faster... how to minify js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.