@import 或 <link>用于导入样式表? [英] @import or &lt;link&gt; for importing stylesheets?

查看:36
本文介绍了@import 或 <link>用于导入样式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪种方法最适合导入多个样式表?一种方法比另一种更有效吗?

Which method is best for importing multiple stylesheets? Is one method more efficient than the other?

推荐答案

我曾经读过这篇关于表演和 vs @import 的文章:不要使用@import;引用其中的一小部分:

I once read this article about performances and <link> vs @import : don’t use @import ; quoting a small portion of it :

如果你使用 LINK 而不是 @import想要样式表下载并行导致更快的页面.

use LINK instead of @import if you want stylesheets to download in parallel resulting in a faster page.

这是最近的(2009 年 4 月),所以应该仍然大部分是真实的 - 由 Steve Souders 撰写,他的名字在前端表演方面非常有名.

It's quite recent (April 2009), so should still be mostly true -- and written by Steve Souders, whose name is quite well-known when it comes to front-end performances.


从更主观的角度来说,我更喜欢从我的主 HTML 文件中使用几个 <link> :这样,我只能快速浏览一下 css 文件的名称——要么看在服务器端查看模板文件,或者在客户端查看生成的 HTML 源代码.


On a more subjective point, I quite prefer using several <link> from my main HTML file : this way, I am able to see in only a quick glance what css files are called -- either looking at the template file on the server, or looking at the generated HTML source on the client side.

这篇关于@import 或 <link>用于导入样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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