How to hide or protect client-side javascript code

How to protect or hide client-side JavaScript code. Is there any way to do this.

thanks

+4
source share
3 answers

Short answer: You cannot / do not.

Longer answer: You cannot hide it at all. It works on the client and cannot be compiled for machine code. However, you can minimize it - this basically confuses it by truncating variable names, removing spaces, etc. Although typically used to save bandwidth, it also makes the code less readable. Note that everything except changed variable names and deleted comments can be easily undone by something like jsbeautufier .. but for a large application it is very difficult to understand the code without any meaningful variable names or functions or comments.

+13
source

There is no such thing as 100% secure javascript code. This is because any code running on the client machine cannot be fully protected. It is best to photograph your javascript and make it hard to read.

It is best to ensure that all vital security codes are executed on the server and allow javascript to perform only simplified client-side user interface tasks.

+6
source

As I know, this is not possible. The only thing you can do is make the code very poorly organized. It will take longer to find out what you are doing.

If you are looking for this for security reasons, you should remember that the only thing that matters in security is a password that does not fit in code. So find a great way to encrypt your stuff. You can find many good ways on the Internet.

-6
source

Source: https://habr.com/ru/post/1341981/


All Articles