Reduce flashing by adding overlay before page constructs DOM
Opened this issue · 4 comments
"run_at": "document_start";
Significantly reduces white flashes.
You're right.
Remember doing some testing that I couldn't discern the difference between "document_start"
and "document_end"
- I think due to the fact that the content script polls the background script to be initialized, but I don't know.
Anyway it's a better default. Added in local dev, will probably merge sometime over the weekend. Got some changes staged. (or make a PR :) Thanks!
update: Changing to "run_at": "document_start"
means document.body
doesn't exist when trying to append the overlay to the DOM. Don't really see how this could work.
… why does it need to talk to the background script at all? A simple content script should be sufficient. Updating the overlay on page-loads should be sufficient for everything but reading books on a single page. Alternatively, force an update to the overlay every 15 minutes. Juts avoid messaging with the background service.
Whether it talks to the background script or not, doesn't affect that you can't add the overlay to the DOM before it's loaded. Right?
It talks to the background script in order to set it's color.
In most cases this color is calculated based on geoposition and the user's configuration in the sense of keyframes. (i.e. "I want 4700K at 8 in the morning; 2700K at sundown"). I haven't tried putting all that logic into the content script, but it seems to me a bad idea to have it recalculated on each page load. Besides, you'd need to request geolocation each time, which I (and I haven't measured!) imagine to not be significantly faster than talking to the background script.
Sure, if you just want a static color, you could easily fit it into a content script. But I don't see how the (geoposition, time) to (color temperature) mapping would fit.