startrev / SnipX

A web extension that can inject CSS and JS snippets into your current browser tab.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

window.location.reload() - hide all background content

arakilian0 opened this issue · comments

Problem

window.location.reload() seems to do the trick for the theme toggle function however, the page is very ugly when the theme is changing. The page has a split second of non-styled content and it completely breaks the ux.

Solution

Hide all non-styled content while the theme is changing and show it once the theme changed.

I also noticed that theme toggle doesn't take into account the current page. This should change to when the user toggles the theme, it's stays on the correct page.

Fixed with commit 9016945.

I think this is solved now because the reload is only occurring when the content is fully loaded. For example:

window.addEventListener('load', (e) => {
  window.location.reload()
}, false)