CSS variables are powerful, you may know that. You can use it for simple tasks, to easily store global variables like colors or fonts or enable dark mode on your website just by toggling a simple class on your body 🤯.
After years using CSS variables I’m still amazed by its power, and I want to show it to you, let’s get into coding some stuff with it.
Unfortunately, CSS lacked support for variables for a long time, so many used CSS preprocessors to have variables, but those ain’t real variables! …
Recently I had a situation where a colleague had to use the YouTube API to retrieve video information like the title, thumbnail and duration. My part on that was to review his code.
All was good, until we reach the duration parse 💥.
Youtube retrieved the duration using this format: