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

Audit: Mitigate reflow / content layout shifts #10085

Open
Malvoz opened this issue Dec 10, 2019 · 7 comments
Open

Audit: Mitigate reflow / content layout shifts #10085

Malvoz opened this issue Dec 10, 2019 · 7 comments
Labels
needs-complete-audit-proposal https://github.com/GoogleChrome/lighthouse/blob/master/docs/new-audits.md new_audit P2

Comments

@Malvoz
Copy link
Contributor

Malvoz commented Dec 10, 2019

(This feature request may be considered part of #5287, but doesn't entail as much, as a single audit.)

The intrinsicsize attribute was proposed to allow developers to have images maintain aspect ratio, proportional to the width of the screen, without causing a user visible reflow.
The attribute proposal was superseded by the new UA-defined styles (Chrome status):

img, video {
    aspect-ratio: attr(width) / attr(height);
} 

The WHATWG HTML spec is also to recommend developers to set width and height attributes (specifically for images, when lazy-loading), however most developers usually don't seek information in the spec and so an audit would increase the likelyhood that developers gets exposed to this recommendation.

As a side note, I think it's important that developers don't disable scroll anchoring by setting (or inheriting) overflow-anchor: none.

Thanks for taking your time.

@addyosmani
Copy link
Member

addyosmani commented Dec 10, 2019

I think specifying dimensions would be useful for us to factor into either a new or existing audit. Native image lazy-loading also recommends developers specify a width and height to avoid relayout:

image

@Malvoz
Copy link
Contributor Author

Malvoz commented Jan 24, 2020

@paullewis worked on pretty much the same thing in #511 (which is inactive and closed) but there's #802 by @samccone, closing this.

@Malvoz Malvoz closed this as completed Jan 24, 2020
@paulirish
Copy link
Member

I prefer the modern context here vs the old issue so let's dupe 511 against this. ;)

@paulirish paulirish reopened this Jan 24, 2020
@paulirish paulirish added needs-complete-audit-proposal https://github.com/GoogleChrome/lighthouse/blob/master/docs/new-audits.md P2 labels Jan 24, 2020
@pawelurbanski
Copy link

It would be useful to provide information how to properly apply width and height attributes. The case is important for the picture element and the img element required by picture.
There can be possible association of width and height specified at the img tag as the dimensions the browser should display the image. Making more clear what is the relation to media queries and sizes attribute would be useful.
For example:
The page has an image that is: 1500x1500 pixels. It is ment to be displayed on mobile devices of max-width: 400px for most mobiles use screens at 4 DPI.
What would be a proper markup using width and height to hint the ratio using the picture element with a source element pointing at this image with a media query.

@Malvoz
Copy link
Contributor Author

Malvoz commented Feb 6, 2020

@pawelurbanski there's a proposal to introduce width and height for <source> in whatwg/html#4968. Until we (hopefully) have that; for <img> I'd personally specify the intrinsic size of the image file that is to be displayed on mobile/small devices since they generally perform slower than larger devices.

@pawelurbanski
Copy link

pawelurbanski commented Feb 6, 2020 via email

@paulirish
Copy link
Member

There are now a few audits implemented that target understanding/mitigating Layout Shifts.


There's also now a new webplatform feature, Font Metrics Override Descriptors, that has potential to help more. It's shipping in Chrome 87.
https://gist.github.com/xiaochengh/da1fa52648d6184fd8022d7134c168c1#use-case-reduce-layout-shifting-caused-by-web-fonts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-complete-audit-proposal https://github.com/GoogleChrome/lighthouse/blob/master/docs/new-audits.md new_audit P2
Projects
None yet
Development

No branches or pull requests

4 participants