---
title: "Comment by Max on \"How to Make the Perfect Dark Mode Switcher\" | Hashnode"
description: "This is a great approach. It's the only one I've tried that's actually worked. I just wanted to add one thing. For mobile bf cache, I added a pageshow event lis"
url: "https://hashnode.com/posts/how-to-make-the-perfect-dark-mode-switcher/62baa636f2e6c7d70c125a7d/comment/67b307b850cb5c730d0d566a"
---

[Discussion](https://hashnode.com/posts/how-to-make-the-perfect-dark-mode-switcher/62baa636f2e6c7d70c125a7d)

Comment [How to Make the Perfect Dark Mode Switcher](https://hashnode.com/posts/how-to-make-the-perfect-dark-mode-switcher/62baa636f2e6c7d70c125a7d)

[Max](https://hashnode.com/@maxsheridan)

[Feb 17, 2025](https://hashnode.com/posts/how-to-make-the-perfect-dark-mode-switcher/62baa636f2e6c7d70c125a7d/comment/67b307b850cb5c730d0d566a)

This is a great approach. It's the only one I've tried that's actually worked. I just wanted to add one thing. For mobile bf cache, I added a pageshow event listener to the deferred section of script so that the preference would persist. Without it, it wasn't — at least on Android Chrome and Firefox. Thanks again for the awesome tutorial!
