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.
Asked
Active
Viewed 5,837 times
-2

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

Muhammad Asim
- 379
- 1
- 4
- 14
-
Nope, it can't be done. If you want to hide it, you need to do something server-side. – Scimonster Sep 09 '15 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 Sep 09 '15 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 Sep 09 '15 at 16:22
-
thanks dud it's really helpful. – Muhammad Asim Sep 09 '15 at 16:25
1 Answers
6
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.