Support » Plugin: WP Night Mode » dark mode and cached pages problem

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author markoarula



    that is the main issue and i will try to solve it as soon as possible.

    I’ll let you know as soon as I solve this problem.

    Best regards

    this site also use dark mode(custom code) and does not have any problem with cache.(Of course I might be wrong)
    This may give you a clue to the problem
    sorry,I am little slow in english
    best regards

    Same problem here :(. Have you found a solution by any chance? Otherwise it’s a great plugin!

    Hi. How can i use this plugin without any caching problem for this websites:

    I’m tries to using your awesome plugin but in caching mode i’ve seen some problems.

    • This reply was modified 7 months, 1 week ago by Increase SEO.

    I think I’ve found the culprit.

    The JavaScript file public/js/wp-night-mode-public.js has a function, wp_night_mode_load_cookie() that loads the cookie and if WP Night Mode is enabled, it adds the class ‘wp-night-mode-on’ to the body.

    It seems this script is loading deferred and the ‘wp-night-mode-on’ class is sometimes added to the body after the whole page has loaded. This causes the dark mode to activate too late.

    I think I solved it (well, it’s a hacky solution) by adding the following JavaScript after the <body> tag in the header.php (find it in your theme editor):

    var nmCookie=document.cookie.match(“(^|;) ?wpNightMode=([^;]*)(;|$)”);nmEnabled=nmCookie?nmCookie[2]:null,”true”===nmEnabled?document.body.classList.add(“wp-night-mode-on”):document.body.classList.remove(“wp-night-mode-on”);

    This is minified code. What it does: the cookie is loaded, and if WP Night Mode is ‘true’, then directly add ‘wp-night-mode-on’ to the classes of the body. Not sure if this is right, but it solved my problem.

    i want to use this for this domain قیمت دلار


    Thank you @ivarvanwooning for your fix proposal, but it does not work here: In my case, the problem appeared when I installed another plugin (LoftLoader) whose cookie is cached (by WP Fastest Cache) before WP Night Mode. Because it is cached first, it defers the loading of the JavaScript of “WP Night Mode”, hence creating the flashing issue. Excluding one of the two cookies from caching solves the flashing issue, but slows down any return to the homepage by at least 2-3s.

    Does anyone know how to force the WP Night Mode cookie to be cached first?

    Best regards from Delhi,


    Hi guys
    Forgive me for poor English first. Unfortunately, although I searched a lot, I was not able to open a new topic, so I am asking my questions here, please help.
    I want to transfer a site written with to WordPress. Please tell me what to do.
    This is the site

    If the page is cached the page will always flash the previous colors every time I load a new page.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.