Is there anyway to hide or secure my javascript code. Because anyone can easily see my javascript logic on my website using view page source and it's harmful for me. Please tell me any method you know for securing the javascript code or for making it difficult to understand using any encryption method with cannot easily decrypt.
-
Nope, it can't be done. If you want to hide it, you need to do something server-side.Scimonster– Scimonster2015-09-09 16:22:03 +00:00Commented Sep 9, 2015 at 16:22
-
If you need to do things with private code, do it on the server. If the browser can run the JavaScript, a person can see it.Pointy– Pointy2015-09-09 16:22:16 +00:00Commented Sep 9, 2015 at 16:22
-
You can't. One the JavaScript hits my browser, I can see it and do what I want with it.gen_Eric– gen_Eric2015-09-09 16:22:27 +00:00Commented Sep 9, 2015 at 16:22
-
thanks dud it's really helpful.Muhammad Asim– Muhammad Asim2015-09-09 16:25:13 +00:00Commented Sep 9, 2015 at 16:25
Add a comment
|
1 Answer
You can't. Don't put sensitive code, keys, information, or logic on the client. The only thing you can do is make it harder to read by running your code through an obfuscator.