| 33 | Understanding the Dangers of @extend |
@extend is certainly powerful, but it can cause bloated output styles if not used carefully.
The example illustrates how just a couple of @extend uses can quickly spiral into some bloated output. All that’s happening is that the .small-icon class is extended onto two other areas. However, where it’s being extended is a little messy. There’s a couple of nested selectors, and they use commas. So Sass has to add all of those class permutations onto the original class, which leaves us with the bloated output you see.
This example shouldn’t suggest that you should never use @extend. Instead, it should illustrate that when choosing between a mixin or extend, you need to think about how you might be using it. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access