Performance: String types and concatenation
This affects CSS generation speed and final CSS file size, impacting page load and render time.
$color: "red blue green";
$color: "red" + " " + "blue" + " " + "green";
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple '+' concatenations in Sass | 0 (preprocessing only) | 0 | 0 | [X] Bad |
| Single string literal | 0 | 0 | 0 | [OK] Good |
| Interpolation with #{} | 0 | 0 | 0 | [OK] Good |
'Hello' and 'World' in Sass?$greeting: 'Hi'; $name: 'Alice'; content: $greeting + ', ' + $name + '!';
$part1: 'Good'; $part2: 'Morning'; content: $part1 + $part2;
'btn-' with a variable $color that can be 'red' or 'blue'. Which Sass code correctly creates the class name .btn-red or .btn-blue?Pass the test and this pattern moves unknown