The site uses a series of high resolution images from 2500px .
pageSpeed of course swears, so I try to use the modern srcset attribute for images:
* { margin: 0; padding: 0; box-sizing: border-box; } img { max-width: 100%; margin: auto; } <article> <img srcset="https://dummyimage.com/2560x400/333/fff 2x, https://dummyimage.com/1280x400/333/fff 1x" sizes="(min-width: 1280px) 1280px, 100vw" alt="A title"> </article> For a high resolution, I use it at 2500px , and for a normal one, I make the same pictures at 2 times lower resolution.
An example img entry for a real project:
<img src="images/img-1-1x.jpg" srcset="images/2x/img-1-2x.jpg 2x" alt="" class="img-fluid"> As a result, for all the "possibilities" pagespeed swears at these images and swears at img-1-2x.jpg Ie On phones, instead of displaying img-1-1x.jpg , a large picture is displayed.
And such problems are only for mob. devices:
For desktop everything is fine, speed 90+ !
On the advice of using Echo.js lazy load , but this lazy load on phones (especially with a bad Internet) does not load all photos.
Update:
As it turned out the record:
<img srcset="https://dummyimage.com/2560x400/333/fff 2x, https://dummyimage.com/1280x400/333/fff 1x" sizes="(min-width: 1280px) 1280px, 100vw" alt="A title"> not valid !
When using the sizes attribute, the entry should be similar to this:
<img srcset="https://dummyimage.com/2560x400/333/fff 1280w, https://dummyimage.com/1280x400/333/fff 640w" sizes="(min-width: 1280px) 1280px, 100vw" alt="A title"> After reviewing a video tutorial with a recommendation about compressing an image in squoosh.app , I made images with .webp resolution. Connected using picture :
<picture> <source srcset="images/Image-1x.webp 1x, images/2x/Image-2x.webp 2x" type="image/webp"> <img src="images/Image-1x.jpg" srcset="images/2x/Image-2x.jpg 2x" alt="" > </picture> Images in the .webp format weigh about 200-300 кб , despite the fact that in high resolution it is about 2 MB.
As a result, the speed on the pages dropped to 10 - 13 , and images are displayed only in chrome. It is the latest version of firefox, but for some reason, it does not display pictures.
! And it is not always possible to optimize all images, i.e. change the size or resolution, and there are many such pictures on the site.
Question: Why does a huge resolution work for phones, but not reduced when writing <img src="images/img-1-1x.jpg" srcset="images/2x/img-1-2x.webp 2x" ... ?
How to use srcset , is it worth using this attribute at all?
What are the possibilities to optimize images without losing quality, but with saving speed for mobile? devices (cross-browser lazy load or any other methods, the fallback method not familiar to me :))?



img srcset, but for some reason it doesn't work for me pagespeed swears at 2x (large) image, although in theory it should display 1x. - HamSter<picture>, as a complete solution. - Andrey Fedorov