3 ms·
> (...and IMHO 4K selectors is a lot more than any sane page should use...) Open gmail, do this in the console: document.styleSheets[2].cssRules.length A
by bzbarsky 13y ago
> (...and IMHO 4K selectors is a lot more than any sane page should use...)
Open gmail, do this in the console:
document.styleSheets[2].cssRules.length
As of today I see "7343". It's possible they only do that in browsers other than IE9, of course.
In any case, for large sites with site-wide stylesheets that have styles for everything on the site, it's easy to end up with thousands of rules. A simple example is github, which on the front page has this as of today:
<link href="https://github.global.ssl.fastly.net/assets/github-b836a3967c04ec8b8bfdd101d2226064cb18f45d.css" media="all" rel="stylesheet" type="text/css" />
<link href="https://github.global.ssl.fastly.net/assets/github2-91575e4b8f601c887ca6b13c6f78d06f03af775f.css" media="all" rel="stylesheet" type="text/css" />
Guess why? The first sheet has 2878 rules, the second has 2865. So together they're over the 4096 limit.
- moron4hire 13y agoYes, but gmail is a nightmare of an application. I use it because it works, for various values of "works", but it has a lot of insanity inside of it.
- bzbarsky 13y agoIs github a nightmare too? The paragon of wondrous design that is the Huffington Post has a bit over 4k rules, spread over 5 stylesheets. msnbc.com also has a bit over 4k rules, spread over 5 stylesheets. It's pretty easy to find sites with 2-4k rules (Outlook Web Access, BBC front page, CNN front page, twitter, Google docs, whitehouse.gov, the Facebook login page, officedepot.com, washingtonpost.com, youtube, I'm sure I could find plenty more). All of which is to say, your typical website has more CSS than most people think.
- moron4hire 13y agoUhm, are these supposed to be arguments against me? That it's common for all of these sites, who have massive surveillance and SEO structures built into them, to have gigantic stylesheet collections doesn't change the fact that they are bloated nightmares of code. If I said, "filing taxes is a nightmare", and you said, "oh yeah, but what about all the other people who file taxes, some of them even more complex than yours?" That wouldn't change the fact that filing taxes is a convoluted, intentionally obfuscated, Lovecraftian construct, summoned forth from the depths of Hades itself.
- bzbarsky 13y agoThe large stylesheets have nothing to do with the SEO bits. They have to do with having a site with a wide variety of different-looking pages and wanting to have a single site-wide stylesheet, instead of having dozens or hundreds of smaller stylesheets. Whether that's a useful thing to do or not obviously depends on how your maintenance for the site is set up, how your CDN works, and probably other things I have no idea about; design of this sort of site is not my area of expertise. And while I agree that all of these sites have a lot of complicated styles and scripts going on, I have a hard time believing that a site of the sort I just described can be created without ending up with a fairly complicated stylesheet. If your position is that having such a site (variety of different kinds of pages) should be a non-goal, I can't agree with that: there are plenty of reasons to want a site like that. If the argument is that having a single stylesheet to rule them all in that situation is bad for maintainability, I don't have a good response: as I said I've never maintained such a site, so I don't have a good feel for what the maintenance tradeoffs are. Fully agreed on the taxes. ;)