News for hackers. Stuff that matters.
Re:Image optimization decreased website's page weight by 62% by l5870uoo9y on Monday July 16, 2018 @09:07AM (#17540969)
<picture> <source srcset="sample_image.webp" type="image/webp"> <source srcset="sample_image.jpg" type="image/jpg"> <img src="sample_image.jpg" alt=""> </picture>

Didn't know you could wrap images in a <picture> tag and browsers (except for IE) will automatically download the .webp version if they support it. Used to do this via a Javascript. I like on-demand scaling where you pass scaling parameters in the url, such as: /200x200/sample_image.jpg.

Re:Image optimization decreased website's page weight by 62% by mimischi on Monday July 16, 2018 @11:22AM (#17541981)
No need to do on-demand scaling via JavaScript either! The srcset attribute is also available in <img> tags and lets you define differently sized images for different viewports: https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimed...