SoylentNews
SoylentNews is people
https://soylentnews.org/

Title    70% Repetition in Style Sheets: Data on How We Fail at CSS Optimization
Date    Tuesday June 27 2017, @12:46AM
Author    cmn32480
Topic   
from the everything-should-be-in-plain-text dept.
https://soylentnews.org/article.pl?sid=17/06/26/221242

martyb writes:

Though somewhat DRY reading, the author provides salient commentary on how many declarations appear in style sheets, how many of those are unique, and offers perspectives on what that means for developing and maintaining web sites. From https://meiert.com/en/blog/70-percent-css-repetition/:

Teaser: Check on how many declarations you use in your style sheets, how many of those declarations are unique, and what that means.

In 2008 I've argued that using declarations just once makes for a key method to DRY up our style sheets (this works because avoiding declaration repetition is usually more effective than avoiding selector repetition—declarations are often longer). I've later raised the suspicion that the demand for variables would have been more informed and civilized had we nailed style sheet optimization. What I haven't done so far is gather data to show how big the problem really is. That's what I've done in the last few weeks.

In a Google spreadsheet I've collected the Top 200 of content sites in the The Moz Top 500, and taken another 20 sites related to web development for comparison. (I've also added 3 of my sites out of curiosity.) I've then used the extremely useful CSS Stats to determine the total number of CSS declarations, as well as the number of unique declarations, to calculate ratios as well as averages: You get the idea as soon as you check out said spreadsheet.

[...] Before we dissect the numbers, let's first quickly establish what one can consider good CSS development practice:

Now, what is a reasonable amount of repetition? From my experience, 10–20%; in other words, 80–90% of a style sheet should consist of unique declarations. Reality, however, looks vastly different, and here we get to the 70%.

I found the analysis to be informative and eye-opening. What have you found to be best practices when it comes to Cascading Style Sheets?


Original Submission

Links

  1. "martyb" - https://soylentnews.org/~martyb/
  2. "using declarations just once" - https://meiert.com/en/blog/20080515/css-organization-and-efficiency/
  3. "nailed style sheet optimization" - https://meiert.com/en/blog/20141009/css-dry-and-optimization/
  4. "Google spreadsheet" - https://docs.google.com/spreadsheets/d/1c-Xan1pkBvlmtRRnlj4WAI_KvTZp9znHhjkZue2HlY4/edit#
  5. "The Moz Top 500" - https://moz.com/top500
  6. "CSS Stats" - http://cssstats.com/
  7. "spreadsheet" - https://docs.google.com/spreadsheets/d/1c-Xan1pkBvlmtRRnlj4WAI_KvTZp9znHhjkZue2HlY4/edit#
  8. "DRY" - https://en.wikipedia.org/wiki/Don't_repeat_yourself
  9. "use declarations just once" - https://meiert.com/en/blog/20080515/css-organization-and-efficiency/
  10. "standardize selector sorting" - https://meiert.com/en/blog/20130130/how-to-order-css-selectors/
  11. "cascade" - https://www.w3.org/TR/CSS22/cascade.html#cascade
  12. "Original Submission" - https://soylentnews.org/submit.pl?op=viewsub&subid=20953

© Copyright 2024 - SoylentNews, All Rights Reserved

printed from SoylentNews, 70% Repetition in Style Sheets: Data on How We Fail at CSS Optimization on 2024-04-25 14:24:15