40 ms·
Push is a bad design. The client should manage the resources on the client not the server. Stuff like resource media queries for instance. How the server can k
by msoad 4y ago
Push is a bad design. The client should manage the resources on the client not the server.
Stuff like resource media queries for instance. How the server can know if user wants dark mode or light mode CSS file?
- jefftk 4y agoI agree on removing it, since it turned out not to work well despite lots of people trying. On your particular question, there's the client hint Sec-CH-Prefers-Color-Scheme: https://web.dev/user-preference-media-features-headers/ https://web.dev/user-preference-media-features-headers/
- msoad 4y ago> The Sec-CH-Prefers-Color-Scheme client hint header is supported on Chromium 93. Other vendors' feedback, namely WebKit's and Mozilla's, is pending. I don't see this header being sent in Chrome 104!
- panopticon 4y agoWorks on Chrome 104 for me: https://sec-ch-prefers-color-scheme.glitch.me/ https://sec-ch-prefers-color-scheme.glitch.me/ Note that the server has to request that header using accept-ch.
- msoad 4y agocurl --head https://sec-ch-prefers-color-scheme.glitch.me/ HTTP/2 200 date: Fri, 19 Aug 2022 18:55:43 GMT content-type: text/html; charset=utf-8 content-length: 936 x-powered-by: Express accept-ch: Sec-CH-Prefers-Color-Scheme vary: Sec-CH-Prefers-Color-Scheme critical-ch: Sec-CH-Prefers-Color-Scheme etag: W/"3a8-iEB3drxZIB7EZYHQL534qwomDuI"
- Koffiepoeder 4y agoUse 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.
- fzfaa 4y ago> How the server can know if user wants dark mode or light mode CSS file? Cookies? Custom header?
- nousermane 4y agoIt is bad design, but more importantly, server push is a (subpar) solution to a problem we shouldn't have in the first place. How exactly modern web ended up in a situation where, first time browser is displaying a single page (with maybe 3 pictures and 2 paragraphs of text), it has to download 300 resources from 12 different servers, including 2 megabytes of minified javascript?
- vbezhenar 4y agoHow many files touches some typical desktop program to display 3 pictures and 2 paragraphs of text? How many megabytes its installation occupies? My bet is that numbers will be comparable. That's the way people write software. Standards and tools should adapt. It makes no sense to complain about it as nothing changes. Every popular JS build tool helps with good practices by building a single minified bundle. Popular JS frameworks are tiny portion of those 2 megabytes. Developers just don't care and you can't do anything about it. You can build better protocols and better tools to make those applications work faster. And developers will leverage those to make their apps even slower. Who cares about 2 MB with 5G?
- okasaki 4y agoEven if so, the javascript doesn't replace the OS "bloat", it adds to it.
- mrjin 4y agoJS is the most abused stuff I guess. Current web apps is a "can we" rather than "should we" approach.
- allendoerfer 4y agoHumanity is a "can we" approach.
- nousermane 4y ago> How many files touches some typical desktop program to display 3 pictures Not sure about typical, but here is rough estimate for the rock bottom of it: "feh" image viewer on Ubuntu/X11: $ strace -e openat -o >(wc -l) feh -F \ one.jpg two.jpg three.jpg 105
- riedel 4y agoPush would IMHO allow nice pub sub if combined with SSE. Particularly for short lived objects one could actually considerably reduce overhead. However, it has been build with the design goal to be an optional feature (as there is no client side API) : I guess it fulfilled at least that goal.