How to Get All Custom Properties on a Page in JavaScript
When I have a question about how to do something with CSS, I often find the answer on CSS-Tricks. I’m guessing that’s true for a lot of you too. It’s been the go-to for CSS knowledge for as long as I can remember.
If one day you find yourself searching for help working with CSS custom properties in JavaScript, you might find yourself on an article on CSS-Tricks written by me. Because, last Monday, June 8th 2020 I have an article published on that invaluable website.

The Process
I used the technique I describe in the article at work for a one-off project. It was fun code to work on. It required a lot of following a trail of different browser APIs. I latch on to work like that. After I had the code working for the project I abstracted it to stand-alone examples. I started writing a draft for my personal blog. But, I wrote too many words. I got bogged down. The draft was over 3,000 words, wasn't finished, and wasn’t very good. I couldn’t motivate myself to finish it. So, it sat. In a branch, unfinished. Not the first blog post I’d abandoned.
Months later, I was listening to an interview with Eva Holland on the Longform Podcast. In it, she talked about how during her career she’d cold pitched articles to editors at publications. This wasn’t the first time I’d heard this from writers, but something about hearing it that time stuck with me.
“I should do that!”, I thought. Specifically, I thought I should pitch the custom properties article I’d given up on to the best web development publication I could think of.
Was that a thing? Is that how articles on CSS-Tricks come to be? Turns out that’s one way. I’d always assumed the only way to get an article on a site like CSS-Tricks was to get an invitation to do so. That is not the case. They have a pitch form available to everyone. Chris even asks you to write a guest post on his site.
So, I pitched the article idea. It wasn’t perfect and the draft wasn’t done. Chris got back to me in a few days and said, “go for it.” It took me about a month to get back up to speed on the code and write a full draft. I’m a slow writer. Within a few days of submitting the draft, Geoff began the editing process. We did a few rounds of copy edits, small style updates, and checks to make sure we had consistent and accurate code samples and CodePen links. June 8th was the day that fit the publishing calendar. And now I’m super excited to have it live.
A post like this doesn’t get a million comments or make the front page of Hacker News. That’s not its purpose. A post like this exists for the long term. It’s a utility that will sit in wait until the day you need it. On that day, it’ll be waiting for you, ready to help.
Also
While you’re here, a quick reminder that Black Lives Matter and that we should defund and abolish the police.