For reference: SCSS .extend()
Similar post on this question: Using extend for clearfix
Say I was to make a handful of classes that I could extend and reuse throughout a project:
For example a class could be:
//common boilerplate for most of my parent divs
.scaffold
{
position: relative;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
//or a typical clearfix
.group:after {
content: "";
display: table;
clear: both;
}
Say I had a dozen of these classes with various purposes and/or differences within the attributes. At what point does extending the class become hurtful towards performance vs helpful? For example - if this class had say 50 commas of various classes
Example of written one of the SCSS classes
.site-header
{
@extend .group;
@extend .scaffold;
background: papayawhip;
border-bottom: 1px #ccc solid;
}
Example compiled clearfix could beCSS
.group:after, .site-header, .route-nav, .main-article, .article-header, .side-bar, .site-footer
//this could go on for a while
{
content: "";
display: table;
clear: both;
}
Example HTML
<!DOCTYPE html>
<html lang="en">
<body>
<header class="site-header">
<nav class="route-nav">
<nav>
</header>
<article class="main-article">
<header class="article-header"></header>
</article>
<aside class="side-bar">
</aside>
<footer class="site-footer">
</footer>
</body>
</html>
I feel like this could be one of the DRY—est methods to writing css. I feel like this approach could become very efficient and successful after writing just a few sections of a page. Moreover, majority of these classes could be refined and used through many project. I really want to experiment with it but I fear it could cause some performance issues in the long run, esp when classes start using pseudo-classes like :after :before.
Would there be a performance hit vs just adding the classes or writing a mixin? Does anyone have any statistics to backup the best route?