33Understanding 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. ...

Get Pragmatic Guide to Sass 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.