简体   繁体   English

如何隐藏JavaScript文件?

[英]How to hide a javascript file?

My question is : how can you hide a javascript file even if you need to use it ? 我的问题是:即使需要使用JavaScript文件,如何隐藏呢?

It is possible to denied access to the source code of a javascript file ? 是否可以拒绝访问javascript文件的源代码? Like if I insert it in my page, functions and other stuff will work but when someone try to access it directly or whatever, it will fail. 就像我将其插入页面一样,功能和其他内容也可以使用,但是当有人尝试直接访问它或进行其他操作时,它将失败。 Any ideas ? 有任何想法吗 ?

I've done some research but didn't found what I really wanted. 我已经做了一些研究,但没有找到我真正想要的。

The short answer, no it can not. 简短的答案,不,它不能。

If its being executed, its being seen. 如果它被执行,它就会被看到。

Because javascript is an interpreted language (not compiled) a copy of the source code has to be copied to the users computer. 由于javascript是一种解释性语言(未编译),因此必须将源代码的副本复制到用户计算机上。 There is no way to stop them from looking at it on their hard drive or using the built in functions of their browser. 无法阻止他们在硬盘驱动器上浏览或使用其浏览器的内置功能。

If you're transmitting a file to a user, they can look at it. 如果您要将文件传输给用户,他们可以查看该文件。

The only to guarantee a user can't look at the contents of a file is to not send it to them. 保证用户看不到文件内容的唯一方法是不将文件发送给他们。

http://www.stunnix.com/prod/jo/ http://www.stunnix.com/prod/jo/

You can use this tool or similar ones to make it harder for your code to be human readable, but you can't stop people from looking at the code. 您可以使用此工具或类似工具来使您的代码更难以被人类阅读,但是您不能阻止人们查看代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM