Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark color theme is used for a couple of frames during page load in light-themed browser/OS #291

Open
tophf opened this issue Dec 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@tophf
Copy link

tophf commented Dec 17, 2023

  • Browser: Chrome 120.0.6099.110, Windows 10
  • Screenshot: mp4 recording
  • Additional context: OS and browser are using light theme, the site uses "follow system mode".

Seems to be caused by defer attribute on the main script:

<script defer src="/js/main.js?v={{ config "appCommitSHA" }}"></script>

I've used local overrides in devtools to verify that removing this attribute fixes the issue. There seems to be no adverse effects either, apparently because you use a listener for readystatechange. The blocking mode of execution doesn't seem to slow down page load here, but if you are concerned, you can add a Link HTTP header with the URLs of scripts and stylesheets to ensure they're preloaded simultaneously with the html, e.g. greasyfork.org does it.

P.S. Chrome started to insert paint frames overly aggressively this year when the number of tags in body exceeds some arbitrary threshold, which is why in Stylus I've moved the entire contents of body to a template in head and then I just add it back into body at the start of the script. This behavior was terrible initially, now they've adjusted the thresholds, but I still use the trick just in case.

@tophf tophf added the bug Something isn't working label Dec 17, 2023
@a0eoc
Copy link
Member

a0eoc commented Dec 17, 2023

Can reproduce on Chromium 110.0.5481.100

Also want to mention that it's currently impossible to use light theme or to change theme setting without JS.
I think the theming system is planned to be reworked with data-flags which were introduced this year.

@tophf
Copy link
Author

tophf commented Dec 18, 2023

Also happens in Firefox. I'm using this userscript as a workaround:

// ==UserScript==
// @name        userstyles.world: force light theme
// @namespace   Violentmonkey Scripts
// @match       https://userstyles.world/*
// @run-at      document-start
// @grant       none
// ==/UserScript==
document.documentElement.dataset.colorScheme = 'light';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants