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

Best Practice about Cumulative Layout Shift #477

Closed
ma00 opened this issue Apr 12, 2022 · 3 comments
Closed

Best Practice about Cumulative Layout Shift #477

ma00 opened this issue Apr 12, 2022 · 3 comments
Labels
Type: Question Further information is requested

Comments

@ma00
Copy link

ma00 commented Apr 12, 2022

I see that pages are performing poorly at pagespeed score because images are missing width and height.
Here the diagnostics:
Image elements do not have explicit width and height
Set an explicit width and height on image elements to reduce layout shifts and improve CLS

here what google suggests as a best practice:
https://web.dev/optimize-cls/?utm_source=lighthouse&utm_medium=lr#images-without-dimensions

@ma00 ma00 added the Type: Enhancement New feature or functionality change label Apr 12, 2022
@vsalvino
Copy link
Contributor

vsalvino commented Apr 12, 2022

Specifying width and height on an image will destroy the ability to have responsive design/responsive images. This means that instead of scaling to the device size or the container width, the image will be a fixed size and overflow outside the size of the device or the container. The techniques described in your linked article provide a work-around this, but only if the web developer and the content editors are very careful with using images with exact aspect ratios, which unfortunately is almost never the case from what I have seen.

If you want to set the width and height of images on your project, you can override the image_block.html template in your project and forcibly set the width and height of the rendition: https://github.com/coderedcorp/coderedcms/blob/dev/coderedcms/templates/coderedcms/blocks/image_block.html

@vsalvino vsalvino added Type: Question Further information is requested and removed Type: Enhancement New feature or functionality change labels Apr 12, 2022
@ma00
Copy link
Author

ma00 commented Apr 14, 2022

apologies I missed an info: I was referring to the cover_image in article_page.html template

@vsalvino
Copy link
Contributor

Closing this due to inactivity. Feel free to re-open if you are still experiencing the issue or have any new information. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants