任何方式从客户端用户隐藏CSS和JavaScript文件? [英] Any way to hide CSS and JavaScript file from the client-side user?

查看:117
本文介绍了任何方式从客户端用户隐藏CSS和JavaScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从客户端用户隐藏CSS和JavaScript文件,并仍然将其嵌入到向用户显示的网页中。

Is there any way to hide the CSS and JavaScript file from the client-side user and still embed it in the webpage shown to the user?

推荐答案

否。 CSS和Javascript必须能被浏览器解析和读取,因此人类可以访问相同的数据。

No. CSS and Javascript must be parsable and readable by the browser, therefore a human can get access to the same data.

可以隐藏/压缩/缩小javascript,但所有通常做的是删除空格和重命名/缩短变量名。脚本仍然有效,任何有趣的如何真正工作仍然可以找出来(可能通过使用一些工具来重新格式化)有一点时间。

It is possible to obscure/compress/minify the javascript, but all that generally does is remove whitespace and rename/shorten variable names. The script is still functional and anyone interesting in how it really works can still figure it out (perhaps by using some tools to reformat it) with a little more time.

缩小的典型原因是减少脚本的下载大小(加快网站性能),但它也具有使代码更难阅读的副作用由人。

The typical reasons for minification is to reduce the download size of your scripts (speeding up site performance), but it also has the side effect of making the code harder to read by a human. One should not count on minification providing any real protection as the code can be reformatted and still understood by anyone determined to do so.

如果你需要保持私人的东西,保持在服务器上的逻辑,不要把它放在客户端。如果需要,客户端可以通过ajax访问基于服务器的功能。

If you need to keep something private, keep the logic on the server and don't put it in the client. Clients can access server-based functionality via ajax if need be.

我从来没有听说过任何人认为有商业理由保护CSS。它是布局/演示文稿格式。

I've never heard of anyone thinking there was a business reason to protect CSS. It's layout/presentation formatting.

这篇关于任何方式从客户端用户隐藏CSS和JavaScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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