pydata-sphinx-theme
pydata-sphinx-theme copied to clipboard
Using picture for themed images?
According to some sites, there is a way to do themed images with picture:
<picture>
<source srcset="dark-mode.png" media="(prefers-color-scheme: dark)">
<img src="light-image.png" alt="An image with two color modes">
</picture>
I don't know how well this is supported, but maybe this is something that can be used for the logo?
For example, if I load matplotlib.org with the Developer Tools open and caching disabled, it takes long enough to load that there are both logos visible for some time until the pydata-sphinx-theme has loaded. With a <picture>, it is my understanding that only one will load (I think).
The doubled logos at load are probably a consequence of #959, though using a picture would presumably avoid downloading both.
I'm not in favor of using picture for images instead of img anywhere in this theme as it would break any downstream sphinx extentions that manipulate images using css.
We could on the other hand consider it for the logo but we need to sort #959 first to check if it's really needed
I checked the link you send and picture are currently not supporting user choices but only media selector. It would force us to leave the current implementation + the picture, forcing your browser to download 3 images everytime. I'm not sure it would solve your issue.
On the other hand, did #1045 solved it ?
I'm not sure that it would download all 3 images, as that kind of defeats the purpose of it. But I think the fix in #1045 is good enough for this,