9:54:07srcset and sizes attributes - [ images on the web | part one ]
From the creator
Using srcset allows us to load in different versions of the same image based on the size of the viewport, or the pixel density of the user's device. This is really helpful as it's one relatively easy way to go about reducing bandwidth for users on lower end devices while ensuring that users on high-end devices get nice, crisp images. One cool thing with this is, it's all done with html, but the downside of it is that it can bulk up your markup a little bit, and we all like having clean markup. The other strange thing is, if you use the sizes attribute, you are actually going to be including media queries in your html... which is kind of strange. But it makes sense that this is all done in the markup and not the CSS with how the spec works, it just creates this weird thing where the markup actually partially relies on the CSS, which is not something we normally ever have to worry about. Link to my code: https://codepen.io/kevinpowell/pen/MzRgJK This video involved quite a bit of research on my part, below are the resources I used if you'd like to do more reading on the subject: https://ericportis.com/posts/2014/srcset-sizes/ https://css-tricks.com/responsive-images-youre-just-changing-resolutions-use-srcset/ https://developers.google.com/web/ilt/pwa/lab-responsive-images https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/ https://medium.freecodecamp.org/a-guide-to-responsive-images-with-ready-to-use-templates-c400bd
Published 2018-12-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





