0

I'm working on a big project and have used one CSS file throughout. I'm now finding that this is becoming unmanageable and unorganised (there are almost 2000 lines so far).

I have read up on different techniques in terms of splitting up the CSS, this is what I have found so far:

1) Split up the CSS into separate files and reference them using LINK tags. The downside to this is it increases the number of server requests.

2) Split up the CSS into separate files and reference them using @import statements. Again the downside to this is increased server requests.

3) Use a CSS parser such as LESS, this lets you split up the CSS into separate files and does not result in additional server requests. However the main downside (for me) of using this is that all developers on the team will need to learn a new method / style of CSS styling. Also I found that I don't get the line numbers in FireBug when using LESS.

So what are the alternative options? Ideally I would just like to split up the CSS into separate files (there will be at least 10) and have a way of referencing them all without impacting performance.

MAX POWER
  • 5,213
  • 15
  • 89
  • 141
  • 1
    you would need quite a bit of content within divided style sheets to really impact performance. In many ways it could improve performance if you only load relevant css files per page and maintain a global stylesheet for sitewide needs. – Kai Qing May 23 '13 at 22:46
  • Using tools such as SASS/SCSS or LESS makes a lot of sense to ease the pain of cross browser compatibility and mobile friendly coding in CSS. – Bjoern Rennhak May 23 '13 at 22:57

1 Answers1

1

I like using a global stylesheet supported by page-specific stylesheets to make it easier to manage.

You're correct that once it gets to 2000+ lines it can be really hard to manage, and I also find that it's too hard to control things later when you want to make changes and your huge 500 page site only has one stylesheet, so things you forgot about may change on some buried page.

I don't think the extra server requests are really that big a deal for the benefits.

I wouldn't go with a CSS parser simply because of the learning curve, and because I don't really think it's worth the effort when extra stylesheets seem to work great.