Hi!
I’m using Ruby, and just noticed that PageSpeed says I’m loading too big images. And it’s right. All these little thumbnails are loading at 2000px wide. There’s NO browser size that makes sense for.
Here’s the relevant code from the loop.hbs partial.
{{#if feature_image}}
{{#if featured}}
<img
class="post-image u-object-fit"
src="{{img_url feature_image}}"
alt="{{title}}"
loading="lazy"
>
{{else}}
<figure class="post-media">
<div class="u-placeholder same-height rectangle">
<img
class="post-image u-object-fit"
srcset="{{img_url feature_image size="s"}} 400w,
{{img_url feature_image size="m"}} 750w,
{{img_url feature_image size="l"}} 960w,
{{img_url feature_image size="xl"}} 1140w,
{{img_url feature_image size="xxl"}} 1920w"
sizes="600px"
src="{{img_url feature_image size="l"}}"
alt="{{title}}"
loading="lazy"
>
</div>
</figure>
{{/if}}
{{/if}}
I think two different things are going wrong here.
(1) There’s no attempt to use a srcset at all for featured images, and since they’re packed into cards on the index page, there really should be.
(2) For reasons I’m stumped on, non featured images are still loading at 2000px, despite this srcset. [I’m using Chrome, and PageSpeed says the same thing.]
srcsets are not really my forte, but my understanding of this code is that it should be grabbing the 750px (“m”) size (because 750px is the first one >600px), or if the browser doesn’t support srcsets, it should grab the “large image”, which I guess I’d assumed was something reasonable, but maybe that’s the problem?