---
title: "Discussion on \"How to Make the Perfect Dark Mode Switcher\" | Hashnode"
description: "Discussion on \"How to Make the Perfect Dark Mode Switcher\". Allow your website to support a user's preferences and easily be switched"
url: "https://hashnode.com/posts/how-to-make-the-perfect-dark-mode-switcher/62baa636f2e6c7d70c125a7d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Make the Perfect Dark Mode Switcher](https://webartisan.info/how-to-make-the-perfect-dark-mode-switcher?utm_source=hashnode&utm_medium=feed)

Allow your website to support a user's preferences and easily be switched

Jun 28, 2022 · 6 min read · webartisan.info  
Updated Jul 5, 2022  
Read the article

-   [#frontend-development](https://hashnode.com/tag/frontend-development)

## Written by

[JD Lien](https://hashnode.com/@jdlien)

@jdlien · Edmonton, Alberta, Canada

  
[View profile](https://hashnode.com/@jdlien)

I teach people how to be awesome devs.

I have been developing websites professionally since 1999 and have used a number of technologies and watched the evolution of the web since its early days. I write about PHP, Laravel, Tailwind, and topics about improving your career as a developer.

## Responses 1

Markdown supported · ⌘↵ to post

[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!
