Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个应用程序,并且在代码中包含一些重要信息,例如 IP 和必须是私有的东西。我使用 apache web 服务器作为服务器,想知道是否有任何方法隐藏 javascript 代码或将其移动到根文件夹之外?
不,根据定义。Javascript 代码在客户端计算机上运行。这意味着客户端必须有权访问 Javascript 源代码才能正常工作。您可以使用 AJAX 隐藏某些数据,直到需要它,但即使这样,客户端(以及任何使用 Firebug 的用户)也能够查看它。
“隐藏”它的唯一方法是通过某种混淆实用程序或缩小 javascript。但是,不幸的是,一旦 javascript 代码进入浏览器。您对此无能为力。