js文件的安全性 [英] security of js files

查看:90
本文介绍了js文件的安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏我的js文件,所以没有人可以查看或下载它有什么办法吗?

i want to hide my js file so no one can view or download it is there any way ?

推荐答案

没有。因为JS代码是源代码,并且它在客户端浏览器上执行,所以无法阻止代码被读取 - 除非没有提供。浏览器必须读取teh文件,编译它并执行相应的代码,但它是作为源代码提供的,如果浏览器可以读取它,那么用户也是如此。



如果您担心安全性,那么使用JavaScript是一个糟糕的想法 - 将代码移动到服务器,以便只将结果发送到客户端机器。
No. Because the JS code is source code, and it is executed on the client browser there is no way to prevent the code being read - except to not provided it. The browser has to read teh file, "compile" it and execute the appropriate code, but it is delivered as source code, and if the browser can read it, so can the user.

If you are that concerned about security, then using JavaScript is a poor idea - move your code to a server so that only the results go to the client machine.


这篇关于js文件的安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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