I have modified the CSS of my Ghost blog to enable a dark theme.
Currently what I am doing is, add
dark CSS class to the
body element on the
document.ready event by checking a property stored in local storage.
As you can see/understand, it takes some time to fire the
document.ready event with every page load and initially the white theme has been set. This is resulting in a white flash before enabling the dark theme at every page load.
Press Alt + N together on technews.lk if you want to test it yourself.
Can anybody suggest me a solution for this?
- Can we use a session and load a CSS file based on that?
- Can a service worker do the CSS class addition? (I guess it’s not possible since the response is readonly in service workers)