简体   繁体   English

在浏览器中禁用显示.css和.js文件内容

[英]Disable display of .css and .js files content in the browser

Before this question I asked about disabling file and folder listing and I found an answer that this can be done with a file called .htaccess. 在问这个问题之前,我问过关于禁用文件和文件夹列表的问题,我发现一个答案可以通过名为.htaccess的文件来完成。 For disabling folder listing I write Options -Indexes in the .htaccess file and place it in the parent folder, on the other hand for disabling display of files content in the browser I write Deny from all. 为了禁用文件夹列表,我在.htaccess文件中写入Options -Indexes并将其放置在父文件夹中,另一方面,要在浏览器中禁用文件内容的显示,我则全部拒绝。

The above part functions good, but when a putted the .htaccess file for disabling display of files content in the css or js folder, it disables display of files and also blocks the functionality of them (.css and .js). 上面的部分功能很好,但是当放置.htaccess文件以禁用css或js文件夹中文件内容的显示时,它将禁用文件的显示并阻止它们的功能(.css和.js)。

Is there an answer that disables the display of files in the browser but allows the functionality of them? 是否有一个答案可以禁用浏览器中文件的显示,但允许其功能?

Thank you 谢谢

No. 没有。

You can turn off directory listings because nothing needs to see them. 您可以关闭目录列表,因为不需要查看它们。

You can't turn off display of CSS or JS because the browser has to be able to see them in order to use them for what they are designed for. 您无法关闭CSS或JS的显示,因为浏览器必须能够看到它们才能将其用于设计目的。 Anything the browser can see, the user can see too. 浏览器可以看到的任何内容,用户也可以看到的。

可以禁用文件列表,但是您不能保护它们,因为它们是网站加载样式或功能所必需的...

Try looking up minifying and obfuscating. 尝试查找缩小和混淆。

Minifying makes your files harder to read. 缩小会使文件更难阅读。 Obfuscating can completely encode your files (only tried with JS so far myself). 混淆可以完全编码您的文件(到目前为止,只有我自己使用JS尝试过)。 But be sure to keep a backup of your files, because once encrypted, you can't go back. 但是请务必保留文件的备份,因为一旦加密,就无法返回。

Here is a link for obfuscating JS files: 这是混淆JS文件的链接:

Obfuscate JS 混淆JS

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

相关问题 仅禁用浏览器中的某些 js 文件 - Disable only certain js files in a browser 有没有办法禁用自动完成与 JS/CSS display none 属性的使用? - Is there possibly a way to disable the use of autocomplete with JS/CSS display none attribute? 如何在浏览器中显示markdown内容(可能使用markdown.js?) - How to display markdown content in browser (probably using markdown.js?) 控制浏览器缓存在apache中更改js和css文件的最佳方法? - Best way to control browser caching of changing js and css files in apache? 根据当前浏览器加载单独的.css和.js文件集 - Loading a separate set of .css and .js files based on current browser 如何使浏览器请求新的js和CSS文件 - How to make browser request new js and css files 如何让浏览器为https站点缓存CSS和JS文件? - How to let the browser cache css and js files for a https site? 是否有用于优化JS / CSS文件的浏览器插件? - Are there any browser-plugins for optimizing JS/CSS files? 所有外部js和css文件上的Gulp和Browser-sync 404 - Gulp and Browser-sync 404 on all external js and css files Javascript HTML DOM 不能在浏览器中工作,但 html、css 和 js 文件可以工作 - Javascript HTML DOM is not working in Browser but html, css and js files work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM