[英]Shortcut to load multiple stylesheets/scripts in the same folder
I have been working on a web page and would like to load multiple stylesheets in an external library. 我一直在网页上工作,想在外部库中加载多个样式表。
Unfortunately, this library has many CSS files spread under the same folder. 不幸的是,该库在同一文件夹下散布了许多CSS文件。
The names are complicated and its such a pain to manually link it one by one. 名称很复杂,手动将其链接起来很麻烦。
As it 因为它
<link type="text/css" href="site/libraries/folder/highlight-areas.css"></link>
...
Is there a shortcut that loads all CSS files on the same page within the folder site/libraries/folder 是否有快捷方式将所有CSS文件加载到文件夹site / libraries / folder的同一页面上
I know how to do this with Ruby on Rails but that is another domain. 我知道如何使用Ruby on Rails做到这一点,但这是另一个领域。
Is there a similar technique available on the client side? 客户端有类似的技术吗?
Thanks in advance 提前致谢
Would the CSS @import function help you? CSS @import函数对您有帮助吗? It allows you to import a CSS file into another, so you could create one master CSS that links to the rest of library styles.
它允许您将一个CSS文件导入另一个文件,因此您可以创建一个链接到其余库样式的主CSS。
Not as such, no. 不是这样,不。 Javascript does not have access to server-side information at all.
Javascript根本无法访问服务器端信息。 (And thank goodness!) However, if you wanted to, there is nothing to stop you from:
(感谢谢天谢地!)但是,如果您愿意,没有什么可以阻止您:
.css
files inside of site/libraries/folder
and served them up as one CSS file upon request. site/libraries/folder
内获取所有.css
文件的内容,并根据请求将它们作为一个CSS文件提供。 .css
files in the folder so it can load them when needed. .css
文件名称的列表,以便它可以在需要时加载它们。 .js
, .css
, or .html
files with the names of the .css
files you want to use. .css
用要使用的.css
文件名更新.js
, .css
或.html
文件。 .css
files into one file and deploys that to your server. .css
文件合并成一个文件,然后将部署到服务器。 Each of these approaches has strengths and weaknesses. 这些方法都有优点和缺点。
1A
requires processing time for every request (unless you cache the results, in which case you might want to consider just going for 2B
) 1B
will not work for clients with Javascript disabled. 1A
需要处理每个请求的时间(除非您缓存结果,在这种情况下,您可能只考虑使用2B
) 1B
不适用于禁用Javascript的客户端。 Both 2A
and 2B
require that you always run your deploy scripts after you make an edit. 2A
和2B
都要求您始终在进行编辑后运行部署脚本。 So it's really up to you. 因此,这完全取决于您。
Just an idea (not tested): 只是一个想法(未经测试):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.