<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/XyWTMwwR9" -->

---
title: The Perfect Dark Mode | daily.dev
description: The dreaded flicker of light mode is a problem that is not limited to static/hybrid websites but extends to pretty much any website that uses JavaScript to...
canonical: https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The Perfect Dark Mode | daily.dev
og:description: The dreaded flicker of light mode is a problem that is not limited to static/hybrid websites but extends to pretty much any website that uses JavaScript to...
og:url: https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9
og:image: https://api.daily.dev/og/posts/XyWTMwwR9.png
og:image:alt: The Perfect Dark Mode
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The Perfect Dark Mode

**[DEV](https://daily.dev/sources/devto)** · 12 min read · 39 upvotes · 3 comments

## Summary

The dreaded flicker of light mode is a problem that is not limited to static/hybrid websites but extends to pretty much any website that uses JavaScript to "hydrate" its components. We need to find a way to be able to run some code and apply the appropriate background-color (and by extension, the theme) before the entire page has loaded.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/sreetamdas/the-perfect-dark-mode-2d7g>

## Community discussion

Top comments from developers on daily.dev.

**@husseinkizz** · 3 upvotes

> Hmm one of the best methods to implement darkmode!

**@neeraj1005** · 0 upvotes

> Nice concept.

**@theophiledt** · 0 upvotes

> Definitely gonna use it on my website.

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The Perfect Dark Mode","url":"https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9"},"datePublished":"2020-11-22T21:40:06.177Z","dateModified":"2021-10-07T14:17:10.317Z","description":"The dreaded flicker of light mode is a problem that is not limited to static/hybrid websites but extends to pretty much any website that uses JavaScript to...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4695024990fd64a731b83f7a9a30a4d4","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4695024990fd64a731b83f7a9a30a4d4","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DEV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/devto","url":"https://daily.dev/sources/devto"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":39},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"css","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"The Perfect Dark Mode"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-perfect-dark-mode-xywtmwwr9","comment":[{"@type":"Comment","text":"Hmm one of the best methods to implement darkmode!","datePublished":"2020-11-22T22:58:47.889Z","url":"https://daily.dev/posts/XyWTMwwR9#c-B3Bs8wWof","author":{"@type":"Person","name":"Hussein Kizz","url":"https://daily.dev/husseinkizz","image":"https://media.daily.dev/image/upload/s--bqCp79lk--/f_auto/v1704865561/avatars/avatar_WgJOIEdxX"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"Nice concept.","datePublished":"2020-11-23T05:15:51.291Z","url":"https://daily.dev/posts/XyWTMwwR9#c-G0MzM-3V-","author":{"@type":"Person","name":"Neeraj Singh Tangariya","url":"https://daily.dev/neeraj1005","image":"https://lh3.googleusercontent.com/a-/AOh14GjX9wb8Rxn2w3QhkBxwR465ZOzsMUAYCuqGnUwwrQ=s100"}},{"@type":"Comment","text":"Definitely gonna use it on my website.","datePublished":"2020-11-23T08:46:01.576Z","url":"https://daily.dev/posts/XyWTMwwR9#c-cmnZ_eHH1","author":{"@type":"Person","name":"Théophile Diot","url":"https://daily.dev/theophiledt","image":"https://avatars1.githubusercontent.com/u/57175294?v=4"}}]}
```

