A number of styles like this should fit into one or more of the following categories...
Attribute redundancy
There may be many repeated attributes in several classes. For example, imagine that you are formatting the titles like this:
h1 { font-weight: bold; font-size: 24px; ... }
h2 { font-weight: bold; font-size: 20px; ... }
h3 { font-weight: bold; font-size: 16px; ... }
...
In this case, you could group the common attributes like this:
h1, h2, h3 { font-weight: bold; ... }
h1 { font-size: 24px; ... }
h2 { font-size: 20px; ... }
h3 { font-size: 16px; ... }
Very specific styles
Another common problem is to always use very specific classes. I’ve seen some systems with a class for each element using the id
as selector.
Imagine something like this:
#link1 { A; B; C; D }
#link2 { A; B; C; D }
#link3 { A; B; C; D; E }
(Being A
, B
, C
, D
and E
any styles)
If you have multiple CSS classes with similar styles, separate what is equal and put into a new class, then use style composition in the attribute class
page elements separating class names by whitespace.
Example:
.link { A; B; C; D }
.link-maior { E }
<a href="#" class="link link-maior">Meu Link</a>
In the example above, the class .link
could contain the general attributes of links, while the class .link-maior
would have a specific format for larger links.
Lack of pattern
A large CSS can also originate in lack of standardization, where each component of each screen is slightly different from the others.
In this case the ideal is to refactor the screens, standardizing them in a set of unified styles.
Generation tool
Another possibility is that some tool is generating styles with too much junk, and several of the above scenarios may occur simultaneously.
I know a tool of this type where all the components of the screen are positioned absolutely. As the positions and styles are unique to each page element, the system generates a CSS file with a class for each element with its position and formatting.
The ideal would be to throw away this tool and make the screens the right way. If not possible, at least divide the styles of each screen into separate files.
Really large and complex system
Finally, it may be that the system is really big enough to justify such a great style.
In this case, the best strategy would be to split the file so that it is not loaded as a whole.
Place the main classes used on all screens in a main file, then divide the rest of the styles into different files following some criteria related to system use, such as groups of screens that are usually used at the same time, user types (admin, normal, ...) or with an individual CSS for each screen.
The overall size of the styles will not decrease, but the loading of the Csss will be diluted between several requests, improving a little the user experience when accessing the system.
Don’t forget to compress
The Questioner (AP) stated that the file is already compressed or "minified", which consists of removing all unnecessary characters such as whitespace and line breaks.
But to make the answer complete, we must not forget that applying the "minification" is an elementary step towards optimizing the response time of any non-trivial application.
You’ve already taken a look at the tab
Audits
Developer Tools in Chrome? A series of items is displayed that can be done to improve the performance of your page– Lucio Rubens
Probably organizing the styles is the best way. Great chance of the problem being the way the sheet itself was made. There may even be a real reason for a leaf to have all this, but I would bet more on not being that case. And gzip has to do is the server, automatically in the negotiation of the protocol, if it is properly configured.
– Bacco
If Gzip has reduced the size so much, it’s because there’s something repeated that probably didn’t need to be (after all, that’s how compressors work...). It’s kind of hard to answer so "in the air" what can be done, but if you post your sheet on Pastebin or another site of this type we could take a look and, who knows, help identify some anti-patterns... P.S. Splitting the sheet into two or more does not help, on the contrary, hinders, and I agree with Bacco on the issue of gzip.
– mgibsonbr
I make my words those of Bacco and mgibsonbr. Probably the best way is to fix your leaf, if possible, of course.
– Franchesco
It’s just that I’ve gathered several leaves into one. That’s why it has this whole size. (ps: the site is responsive, so it increases the sheet size more because it has more lines). The sheet is correct, that’s not the problem. The size is due only to multiple unified sheets. About gzip, I already know it’s done by the server, and I already use ._.
– Alexandre Lopes
I only know that gzipado gets 59KB because I did tests via server.
– Alexandre Lopes
I think if you joined several sheets ctza there are several components in common can unify in css, but if you do this depending can lose readability.
– Skywalker
Look at this, maybe you’ve seen it, http://browserdiet.com/pt/
– Skywalker