如何隐藏在网页中的javascript code? [英] How do I hide javascript code in a webpage?

查看:129
本文介绍了如何隐藏在网页中的javascript code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能隐藏从网页的HTML,当源$ C ​​$ C通过浏览器观看的JavaScript code查看源功能?

Is it possible to hide the Javascript code from the html of a webpage, when the source code is viewed through the browsers View Source feature?

我知道这是可能的混淆code,但我会preFER它是的隐藏的从查看源代码的功能。

I know it is possible to obfuscate the code, but I would prefer it being hidden from the view source feature.

推荐答案

我不知道其他人居然直接解决您的问题,这是从浏览器的查看源文件命令来查看code。

I'm not sure anyone else actually addressed your question directly which is code being viewed from the browser's View Source command.

至于其他所说的,是没有办法保障的JavaScript打算从确定观众在浏览器中运行。如果浏览器可以运行它,那么任何有决心的人可以查看/运行它也。

As other have said, there is no way to protect javascript intended to run in a browser from a determined viewer. If the browser can run it, then any determined person can view/run it also.

但是,如果你把你的JavaScript中附带外部JavaScript文件:

But, if you put your javascript in an external javascript file that is included with:

<脚本类型=文/ JavaScript的SRC =htt​​p://mydomain.com/xxxx.js>< / SCRIPT>

标签,那么的JavaScript code不会立即查看源命令可见 - 只有script标签本身将是可见的方式。这并不意味着就不能只加载外部JavaScript文件中看到它,但你没有问如何保持它的浏览器的查看源文件命令,这将做到这一点。

tags, then the javascript code won't be immediately visible with the View Source command - only the script tag itself will be visible that way. That doesn't mean that someone can't just load that external javascript file to see it, but you did ask how to keep it out of the browser's View Source command and this will do it.

如果你想真正使更多的工作来查看源代码,你会做所有的以下内容:

If you wanted to really make it more work to view the source, you would do all of the following:


  1. 把它放在一个外部.js文件。

  2. 模糊处理该文件,以便最天然的变量名与短版本代替,使得所有不需要的空白被除去,所以它不能没有进一步的处理被读取,等...

  3. 通过动态编程添加脚本标记(如谷歌Analytics(分析)一样)包括.js文件。这将使其更难以得到从查看源命令源$ C ​​$ C一样会有不容易链接点击那里。

  4. 把你要保护你通过AJAX在服务器上检索尽可能多有趣的逻辑要求,而不是做局部处理。

与所有的说,我想你应该专注于性能,可靠性,使您的应用程序极大。如果你绝对要保护一些算法,把它放在服务器上,但除此之外,在竞争是最好的在你做什么,不是有秘密。这就是最终的成功在网络上是如何工作的呢。

With all that said, I think you should focus on performance, reliability and making your app great. If you absolutely have to protect some algorithm, put it on the server, but other than that, compete on being the best at you do, not by having secrets. That's ultimately how success works on the web anyway.

这篇关于如何隐藏在网页中的javascript code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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