Performance: @if conditional logic
LOW IMPACT
This affects CSS compilation time and the size of the generated CSS file, impacting initial page load speed.
@mixin button-style($type) { color: black; background: white; @if $type == 'primary' { background: blue; color: white; } @else if $type == 'secondary' { background: gray; } } .button-primary { @include button-style('primary'); } .button-secondary { @include button-style('secondary'); }
@mixin button-style($type) { color: black; background: white; @if $type == 'primary' { background: blue; color: white; } @if $type == 'secondary' { background: gray; } } .button-primary { @include button-style('primary'); } .button-secondary { @include button-style('secondary'); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using multiple @if blocks generating duplicated CSS | N/A | N/A | Higher due to larger CSS | [X] Bad |
| Using @if with else-if to generate minimal CSS | N/A | N/A | Lower due to smaller CSS | [OK] Good |