如何混淆或使我的JavaScript文件难以理解? [英] How can i obfuscate or make unreadable my JavaScript files?

查看:88
本文介绍了如何混淆或使我的JavaScript文件难以理解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中包含JavaScript脚本,包含JavaScript和jQuery函数。
我的应用程序的所有用户交互都是动态的,它通过jQuery传递给应用程序。

I have JavaScript scripts in my application containing JavaScript and jQuery functions. All user interaction with my application is dynamic and it's passing to the application through jQuery.

当我在客户端上运行我的应用程序时,我意识到通过查看页面源( Ctrl + U ),客户端可以看到我的所有源代码。

What I realized is, when I run my application, on the client side, the client can see my all source code by viewing page source (Ctrl + U).

怎么能我隐藏或做某事使用户无法理解或阅读来源?

How can I hide or do something so that user can't understand or read the source?

我想做像Facebook那样的事情。通过查看Facebook源用户无法重用其源代码甚至无法理解它。

I want to do something like what Facebook does. By viewing Facebook source user can't reuse its source code or even understand it.

我用Google搜索并发现此过程称为混淆,但这不适用于我。

I googled and found that this process is called obfuscation, but this doesn't work for me.

我试过这个:

http://www.javascriptobfuscator.com/default.aspx

http://dean.edwards.name/packer/

http://www.daftlogic.com/projects-online-javascript-obfuscator.htm

甚至我试过
http://www.jasob.com/

但这对我没用。

推荐答案

如果有人真正关心你的代码,他会采取你的工作量n-minifying(用有用的变量/函数名替换随机数)。 加密或打包等其他任何内容都只是蛇油,因为它可以是恢复极其容易。因此,为自己节省一些工作,而不是花钱让应用程序更好。

If someone really cares about your code he will take the workload of un-minifying (replacing random with useful variable/function names). Anything else such as "encrypting" or packing is just snake oil since it can be reverted extremely easy. So save yourself some work and rather spend it on making your application better.

所以:你应该在生产系统上做的唯一事情就是缩小你的JS代码。这使它更小,因此加载更快 - 所以它实际上是一个优势。除此之外,对于那些只是好奇的快速浏览但又不想花时间的人来说,它会降低阅读性。

So: The only thing you should do on a production system is minifying your JS code. This makes it smaller and thus faster to load - so it is an actually advantage. Besides that, it will make it less readable to people who are just curious for a quick look but don't want to spend time on it.

facebook的JS文件示例只是缩小了 - 很可能只是出于带宽/性能原因。

The facebook JS files for example are just minified by the way - most likely just for bandwidth/performance reasons.

缩小JavaScript的最简单方法正在使用谷歌的网络服务: http://closure-compiler.appspot.com/home

请注意它有1MB的限制,所以如果你的JS很大,你可能需要下载基于Java的minifier来在本地运行它。

The easiest way to minify your JavaScript is using Google's web service for it: http://closure-compiler.appspot.com/home
Note that it has an 1MB limit so if your JS is that huge, you might need to download the Java-based minifier to run it locally.

这篇关于如何混淆或使我的JavaScript文件难以理解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆