Performance: SASS compilation to CSS
This affects the page load speed by determining how quickly CSS styles are available for rendering.
<link rel="stylesheet" href="styles.css"> /* Precompiled CSS file linked in HTML */
@import 'styles.scss'; /* Using runtime SASS compilation in browser */
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Runtime SASS compilation in browser | N/A | Multiple reflows due to delayed styles | High paint cost due to style recalculation | [X] Bad |
| Precompiled CSS from SASS | N/A | Single reflow on initial load | Low paint cost with immediate styles | [OK] Good |
.scss files into .css files?style.scss into CSS using the terminal?sass input.scss output.css to compile SASS to CSS.sass style.scss style.css.sass input.scss output.css to compile [OK]style.scss:
$main-color: #3498db;
body {
background-color: $main-color;
}
What will be the compiled CSS output?$main-color holds the color value #3498db.$main-color is replaced by #3498db in the CSS output.sass --watch style.scss style.css but the CSS file does not update when you change style.scss. What is the most likely problem?--watch works--watch option monitors the SASS file for changes and recompiles automatically when saved.style.scss file after editing. -> Option A--watch recompilation [OK]styles/ folder. Which command should you use?sass --watch input/:output/ syntax.sass --watch styles/:styles --style compressed watches the styles/ folder and outputs compressed CSS to the same folder.sass --watch input:output with style flag [OK]Pass the test and this pattern moves unknown