Hey there! Are you working on a Rails project with Sass & Compass? If you're using the Rails Asset Pipeline, check out this question.
We're in the process of developing a large application with multiple use cases and various individually styled pages, catering to different contexts. This means we have a lot of style information to manage.
In our latest project section, we've encountered Internet Explorer's limit of 4095 selectors per stylesheet. Need proof of this limitation? Check out this link.
Now, why not just split the application stylesheet into several smaller ones by design?
The issue is that mixins and selector inheritance won't work across multiple Sass files (not partials), correct?
While the quality of our stylesheets is high, we can't eliminate the excess number of selectors. And it doesn't seem like reducing the amount of selectors should be our top optimization priority. The Sass core team recommends using selector inheritance over mixins when possible to reduce CSS file size, even though it may result in an increase in the number of selectors.
So, what are my options?
I'm considering writing a script that generates additional CSS files, breaking down the main application.css file. These extra files would only be loaded in IE to avoid multiple requests in modern browsers. I'd need a basic CSS parser to divide the application.css file after reaching 4095 selectors at a valid point. And I'd also require a Compass compile-after hook so developers don't need to manually create the IE files for testing purposes.
If you have any better ideas, please share them!
Thanks, Christian