Because feature images are responsive, lazy loaded and their size controlled in CSS, the Casper theme (which I love btw!) shows the first text of an article until the feature image loads, at which point it shifts the text down below the image.
This jank, or Cumulative Layout Shift, is especially jarring on slow, mobile connections.
Recent versions of Chrome and Firefox use the
height attributes of the img tag to calculate the aspect ratio of the yet-to-be-loaded image, thus reserving the correct amount of empty space on the page before the image loads, avoiding the jank.
I tried myself to add hardcoded width and height values to
post.hbs - and it resolved the issue - but I can’t work out how to get the actual width and height values for a feature image and use them in templates.
It would be great to use the actual dimensions of the original image for the values…
Here’s a nice video from Mozilla explaining the causes of the issue and how using width and height attributes on responsive images can help solve it: