A free alternative to Darkmode.js

Darkmode.js made “dark mode in one line” popular, and it is still small and simple. Its last release, 1.5.7, came out in September 2020. Light Switch does the same job with a pull cord instead of a round button, can also switch your own dark styles, and avoids a flash on load. If you want the smallest possible script, Darkmode.js is a little smaller.

Darkmode.js vs Light Switch

Darkmode.js Light Switch
Last release on npm 1.5.7, September 2020. 1.0.0, December 2026, maintained.
Size 7.2 KB minified (2.2 KB gzipped). 7.7 KB minified (3.3 KB gzipped).
How it goes dark A full-screen layer with mix-blend-mode: difference over the page. Inverts the page itself; photos, videos, iframes and background images keep their colours.
Your own dark styles No; it always uses its blend layer. Yes: class mode toggles a class (e.g. Tailwind’s dark) or data-theme instead.
The switch A round floating button. A pull cord with spring physics, a click sound and a flicker; a real button for keyboards.
Remembering the choice Yes (localStorage). Yes, or follow the device, or always start light or dark.
Flash on load The page shows light until the script runs. In <head>, the saved choice is applied before the page is drawn.
Keeping things as they are Class darkmode-ignore, or isolation: isolate. Images and videos automatically, plus data-no-invert or your own selector.

Darkmode.js details from its npm package and repository, checked on 1 December 2026. Versions and licences change, so check the source before deciding: darkmode-js on npm, Darkmode.js on GitHub. Darkmode.js is an open-source project by Sandoche Adittane; Fluri isn’t affiliated with it.

Choose Darkmode.js if…

  • You want the smallest possible script
  • You like its round floating button
  • It already works on your site

Choose Light Switch if…

  • You want a switch people notice and play with
  • Your site already has dark styles you want to switch on
  • You don’t want a flash of light before dark mode kicks in
Try Light Switch live

Questions

Something else? Send us a message.

Is Light Switch really free?

Yes. Light Switch is published on npm as @fluritheme/light-switch under the MIT licence, including for commercial websites. Load it from the jsDelivr CDN or install it with npm. No account, no limits.

Is Light Switch a full replacement for Darkmode.js?

Not in every case. The table above lists what Darkmode.js does that Light Switch doesn’t. If you need those features, Darkmode.js is the better choice.

How do I switch?

Remove the Darkmode.js script and its set-up code, add one script tag for @fluritheme/light-switch (the README has copy-paste examples) and check the options. It takes a few minutes.

Give your website a little life today.

Pick a theme, pay once, paste one line. It’s live in minutes.