41 ms·
Use css variables for colors, then load the relevant set with a 'prefers-color-scheme' media query. No need to serve 2 CSS assets: the difference should be mini
by Koffiepoeder 4y ago
Use css variables for colors, then load the relevant set with a 'prefers-color-scheme' media query. No need to serve 2 CSS assets: the difference should be minimal.
- jefftk 4y agoA stronger version of msoad's point would be deciding whether to push a dark or light image, based on the user's theme.
- msoad 4y agoYou can solve this using the <picture> element. As Github does:https://github.blog/changelog/2022-08-15-specify-theme-context-for-images-in-markdown-ga/ https://github.blog/changelog/2022-08-15-specify-theme-conte...
- jefftk 4y agoWe're assuming here that the site owner wants to push the image.; Having the client request a different image as a follow-up based on the user's preferences is a different solution, and there are lots of specific ways to do that.
- mikewhy 4y agoThat sounds exactly like "The client should manage the resources on the client not the server"
- zamadatix 4y agoNowadays absolutely. Worth keeping in mind HTTP/2 made it into browsers 4 years before that media query though. You can also request that info via header nowadays if you for some reason were really dead set on sending the minimal CSS directly.