Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS Selector Chain Performance
    text
    copied!<p>I will try to explain my question with a little bit of CSS</p> <h2>Option 1</h2> <p>I don't repeat the <code>float:left;</code> all over the place, instead I chain all the class names that are going to float left together.</p> <pre> .one-little-thing, .two-little-things, .three-little-things, .four-little-things, .five-little-things { float:left; } .one-little-thing { color: blue; } .two-little-things { color: red; } .three-little-things { color: yellow; } .four-little-things { color: blue; } .five-little-things { color: green; } </pre> <p>Total Number of Characters: 331 (including spaces, but even if you trim the spaces, the example is going to be valid)</p> <h2>Option 2</h2> <ul> <li>Where I repeat float:left; all over the place, but I get slightly less characters.</li> </ul> <pre> .one-little-thing { color: blue; float:left; } .two-little-things { color: red; float:left; } .three-little-things { color: yellow; float:left; } .four-little-things { color: blue; float:left; } .five-little-things { color: green; float:left; } </pre> <p>Total Number of Characters: 284</p> <p>I did exactly the same thing with both pieces of code here, the second way has less characters, which means less bytes. </p> <p><strong>So my question is this:</strong><br> Does this mean that the second way is better for performance ? What if I had up to ninety-nine-little-things ?</p> <p><strong>Why it concerns me</strong><br> The <code>@extend</code> in Sass allows to for example to <code>@extend .clearfix;</code>, which, if used as in "Option 1" would result in a very, very long selector.</p> <p>So which is the best way ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload