Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add explicit width, height to image #322

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

taylrj
Copy link
Contributor

@taylrj taylrj commented Oct 30, 2022

Issue: Set an explicit width, height and aspect-ratio on image elements

According to page speed insights, there is a diagnostic that suggest to set explicit width, height on image elements.

image

This is what this PR does. We can set the width and height of mobile image as the default value for image elements.
And since we adjust the width and height to fit its containers by css (e.g. width="100%"), it still keeps the aspect ratio of images, such as:

image

The computed width and height of an image is subject to the customized css style (e.g. the value computed by width="100%").

This patch sets an explicit width and height on image elements to
reduce layout shifts and improve CLS (Cumulative Layout Shift).
This patch sets an explicit width and height on image elements utilized
in index page to reduce layout shifts and improve CLS (Cumulative Layout
Shift).
@taylrj taylrj requested a review from duidae October 30, 2022 13:14
@vercel
Copy link

vercel bot commented Oct 30, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-components ✅ Ready (Inspect) Visit Preview Oct 30, 2022 at 1:17PM (UTC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant