Switch theme on DOMContentLoaded event instead of load event

This doesn't fix the issue of the bright flash but makes it shorter.

The `load` event is fired when the page and all resources are fully
loaded while the `DOMContentLoaded` event is fired when initial HTML
document has been completely loaded and parsed, without waiting for
stylesheets, images, and subframes to finish loading.
This commit is contained in:
saltycrys 2020-11-16 01:51:18 +01:00
parent aeed7deb2d
commit bc705ff19d

View File

@ -22,7 +22,7 @@ window.addEventListener('storage', function (e) {
}
});
window.addEventListener('load', function () {
window.addEventListener('DOMContentLoaded', function () {
window.localStorage.setItem('dark_mode', document.getElementById('dark_mode_pref').textContent);
// Update localStorage if dark mode preference changed on preferences page
update_mode(window.localStorage.dark_mode);