Jump to content

Dark Mode & Pro Cache?


reed
 Share

Recommended Posts

Hey y'all! It's been a while since I jumped into the forums, so I'm hoping this is in the right place.

So — I'm using Pro Cache to deliver cached versions of my site pages. It's the absolute best. But I recently added a dark-mode to my site, which first checks for a cookie to set a global <body> class based on the visitor's established preference, and falls back to the user's system-level color scheme with the media query:

@media (prefers-color-scheme: dark)

The problem is, cached pages seem to adopt the mode of the user who first visited the page and triggered the cache? I'm still messing around with it, but if anyone has ideas for how to both cache pages, and deliver each user content in the mode they prefer let me know. Thanks so much!

  • Like 1
Link to comment
Share on other sites

I do such things with a small javascript or AJAX call on doc ready or similar. Or sometimes in the head section of the HTML page, depending what is needed.
So you may add a small JS snippet directly after the opening body tag that checks the user preferences and according the result, add or remove a css class from/to body. (?)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...