如何保护 Javascript 代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/3438923/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to secure the Javascript Code?
提问by Q8Y
Possible Duplicate:
how to prevent your javascripts being stolen,copied, and viewed ?
What is the best way to secure the javascript code & make it hard to understand it and for sure steal it... I know that its impossible to secure it 100% since its client side and all the code the client can see it.. But I need to make it as hard as possible...
保护javascript代码并使其难以理解并确保窃取它的最佳方法是什么......我知道它不可能100%保护它,因为它的客户端和客户端可以看到它的所有代码......但我需要让它尽可能地难...
采纳答案by Tom Gullen
All you can do is minify and obfuscate it.
你所能做的就是缩小和混淆它。
Here is a free obfuscator, there are several around.
这是一个免费的混淆器,周围有几个。
回答by Sergei
回答by Onestone
100% securing of JS code is impossible. Whichever popular packer you use, JSBeautifieris usually able to reconstruct a humanly-readable source from it. Personally, I only use Google Closure Compilerwhich is the best minifier/optimizer currently available.
100% 保护 JS 代码是不可能的。无论您使用哪种流行的打包程序,JSBeautifier通常都能够从中重建人类可读的源代码。就个人而言,我只使用Google Closure Compiler,它是目前可用的最佳缩小器/优化器。

