Making night mode?

Hi, I need to do night mode. it is actually easy to make and many people have done it but have some problems. I need help how to solve them.

at first I had problem with the night mode feature disappearing when I refreshed the page, I solved it now

but if you activate night mode on a standard site and refresh the page

When you refresh the page for a very short time in the original state then goes into night mode.

sample video;
Note: the video is too short 5 seconds

As you can see, the night mode is activated and the page is refreshed and before the original page in white then night mode occurs.

Now let’s look at the reddit night mode here when the night mode is active while renewing the style of the page does not deteriorate directly comes with night mode.
reddit sample

this is the night mode file
night mode zip

I hope I can explain the problem.
I’m open to alternatives
Thank you from now.