我应该仍然打扰保持所有的CSS在一个文件? [英] Should I still bother keeping all css in one file?

查看:108
本文介绍了我应该仍然打扰保持所有的CSS在一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一次,我被更高级的网络开发者(gee,什么时候再次?)思考,我们应该避免管理多个CSS文件,坚持每个项目一个

Once upon a time I was thought by more advanced web developers (gee, when was it again? ;)) that we should avoid managing multiple CSS files and stick to one per project. It helped to improve page load speed and avoid silly mistakes when dealing with a lot overlapping CSS rules.

我的问题是 - 这种方法是否仍然有效?

My question is - is this approach still valid?

有关页面加载性能的争论似乎并没有那么多时下与真棒宽带互联网和聪明的网络浏览器,甚至更真棒的缓存功能。
CSS级联确实很容易出错,但只是对于没有经验的开发人员和有一个CSS样式表并不真正使我们防弹。

Argument about page load performance doesn't seem to hold that much nowadays with awesome broadband Internet and clever web browsers with even more awesome caching capabilities. CSS cascading can indeed be error prone, but just for inexperienced developer and having one CSS style sheet doesn't really make us bullet-proof.

我更喜欢有一组默认样式表整齐地由组件分隔,然后通过CSS连线到一个单一的规则由CSS @import

I think that I would prefer to have a set of default style sheets neatly separated by components, then wire them up into one single rule by CSS @import. This would also allow me to include reset style sheet by default.

任何人都与我在一起?

推荐答案

这不是关于带宽速度,而是http请求的数量,这对移动连接很有意义。

It's not about bandwidth speed but number of http requests, this makes a lot of sense for a mobile connection.

不同的css文件保持项目的模块化是坚实的,因为它可以帮助你保持你的CSS组织你想要的方式,而没有一个文件中的所有代码。然后你可以受益于css预处理器/缩小器,以连接和压缩所有的css文件在一个单一的生产。

However the approach of having different css files to keep the project modular is solid, as it helps you keeping your css organized the way you want it without having all the code in one file only. Then you can benefit of css preprocessors / minifiers to concatenate and compress all your css files in a single one for production.

本文 http://www.igvita.com/2012/06/14/debunking-responsive-css -performance-myths /

有一段有关移动的段落,解释了为什么这是一个好的做法:

has a paragraph about mobile that explains well why this is a good practice:


你最好在初始化,预热的连接下一次性下载所有的CSS内容。通过这样做,您还将帮助用户延长其电池寿命。如果这里有一个优化,那么它是简单的:连接和压缩。

you are much better off downloading all of the CSS content in one shot over the initial, warmed up connection. By doing so, you will also help the user extend their battery life. If there is one optimization to be made here then it is simply: concatenate and compress.

这篇关于我应该仍然打扰保持所有的CSS在一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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