Yesterday, I wrote about how I ditched my Sass build step for vanilla CSS. As part of that process, I ended up refactoring a lot of code in a way that made it simpler and more efficient. For example, my old Sass files were filled with code like this…
Sass supports media query nesting, which vanilla CSS does not. Rewritten for vanilla CSS, it looks like this…
I had so many instance in my CSS file where I was switching from one color to another color for dark mode. Often, white would become black, or black would become white. It was relatively trivial in Sass, but in CSS, it became tedious, especially for declarations with multiple, batched selectors like the example above. So… I ended up creating some new CSS variables that handle the color switch automatically. I setup a
That example above then gets rewritten like this…
Across my entire project, this resulted in a massive reduction in CSS. And this is another big benefit of using vanilla CSS over Sass. By no longer obfuscating the code that gets generated, you have the chance to write better, cleaner CSS. Cheers, Want to share this with others or read it later? View it in a browser. |
Related Post:
- Friend, Accept or Decline a FREE Tote Bag.
- Crocs From $8 | $19 Mattress Topper | $25 Gourmia Air Fryer
- U.S. Airlines’ August 2024 Fuel Cost per Gallon down 4.3% from July 2024; Aviation Fuel Consumption up 1.9% from Pre-Pandemic August 2019
- [Go Make Things] User-defined Web Components
- Coldplay set for MASSIVE debut with their new album
0 Komentar untuk "[Go Make Things] Vanilla CSS and efficiencies over Sass"