Elektrine lite

← Feed

@algernon@come-from.mad-scientist.club

2026-08-11 11:42 UTC

Last night I described an idea for a JavaScript-less theme switcher for my static blog, using a cookie and a little help from Caddy. Today, I implemented both parts. If you visit Chronicae Novis Rebus, you'll find a new menu item: theme. You can select your theme, it'll be stuffed into a cookie, and the site will remember it. No JavaScript, no localStorage, still a static site, with a tiny bit of help from the reverse proxy. I'm pretty darn happy with how it turned out. This will also allow me to add other kinds of themes in the future, too! I have some ideas.

Replies (3)

  • @wink@sup.f5n.org 2026-08-11 11:56

    @algernon@come-from.mad-scientist.club I have to report that clicking all 3 buttons just sets the theme to the light background one that existed when I arrived. Might be LibreWolf blocking some cookie... in my normal Firefox with UBO I got it to work once, then not anymore. If you have logs I'm the guy with a mac and LibreWolf and Firefox and ~20 page hits in the last 3min on /theme/

    Open ##5176912

  • @algernon@come-from.mad-scientist.club doesn’t work in Safari on my ipad

    Open ##5176914

  • Turns out, there was a bit of a caching problem! I had my HTML load /theme.css, which was a real file, so if not loading the light or dark theme, a file was hit, and it had an etag and last-modified, and all that. So when switching to a light or dark theme, the browser would use the cached /theme.css instead of trying to load it again, and getting redirected. Changed the setup so /theme.css doesn't exist anymore, there's /theme-system.css instead, and /theme.css is thus always a redirect. The redirect also sets a query param to force the browser to load the page again too, and re-render it. Now it seems to work correctly.

    Open ##5176915