4 ms·
Why does it download the 2kb if the image dimensions are specified?
by ec109685 8y ago
Why does it download the 2kb if the image dimensions are specified?
- pilif 8y agothe spec says "[…] the image dimensions can be decoded from the first 2KB of the image". It doesn't say anything about when the dimensions are known and I would assume it's using those in that case. However, loading 2KB of an image is enough for most image formats to determine the dimensions even if they aren't specified in the hosting document (because most image formats contain a header specifying dimensions).
- zamadatix 8y agoThe doc states 2 reasons: - If the image is fits in 2kb (icons/ui elements) then they can just do a full decode and not have to lazy load these ui items as the page scrolls. - It allows them to load low resolution versions of progressive image formats rather than stick up a generic placeholder (marked as a future improvement right now).
- deleted 8y ago[deleted]
- ec109685 8y agoFor your first point, reading the specified dimensions from the page would be sufficient to tell the browser whether it's a small image to skip lazy loading.
- NeutronStar 8y agoThe image might be 2kx1k but dimensions specified can be 20x10px. Not a good practice but can occur.