Aspect ratio's effect on CLS

55 views
Skip to first unread message

Vignesh M

unread,
Jul 26, 2022, 4:21:43 PM7/26/22
to web-vitals-feedback
Hello team,

We have a page whose CLS score is pretty bad, we are doubting not specifiying the aspect ratio for images is the main reason there.
If we add the width and height of the images through an external stylesheet, will it be able to reduce the layout shift of the page?
or does it need to be only an inline height and width attribute?

Thanks,

Philip Walton

unread,
Jul 26, 2022, 5:13:35 PM7/26/22
to Vignesh M, web-vitals-feedback
Hey Vignesh,

There are a number of ways to control the size of an image before it loads in order to avoid layout shifts. My colleague, Jake Archibald, recently wrote a nice post on the subject that you may find helpful: https://jakearchibald.com/2022/img-aspect-ratio/


--
You received this message because you are subscribed to the Google Groups "web-vitals-feedback" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-vitals-feed...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web-vitals-feedback/7269038e-e706-41bf-ad80-a0fc9f9a8e11n%40googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages