Hacker News new | past | comments | ask | show | jobs | submit login

It can still be done with some JS trickery: set the SVG file as background-image as norms, this will be the fallback in CSS, then during page-load use JS to read that same then-loaded SVG file into an in-DOM (but hidden) SVG element so the var() properties get resolved, then re-serialise the SVG element with computed style properties and set that as the page background via a data: URI - or preferably: an ObjectURL - the downside to this approach is you’d have to re-run the code every time you want to update it, which won’t work well for pages that update var() properties at 60fps…



I had no idea you could serialize an SVG with computed properties. Huh! Very clever.

That is a lot of trickery involved indeed, I applaud your ingenuity!


That's hilarious, I guess if it works...




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: