question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Audit: Mitigate reflow / content layout shifts

See original GitHub issue

(This feature request may be considered part of https://github.com/GoogleChrome/lighthouse/issues/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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Malvozcommented, Feb 6, 2020

@pawelurbanski there’s a proposal to introduce width and height for <source> in https://github.com/whatwg/html/issues/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.

2reactions
addyosmanicommented, Apr 15, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimize Cumulative Layout Shift - web.dev
Cumulative Layout Shift (CLS) is a metric that quantifies how often users experience sudden shifts in page content.
Read more >
Reduce ad-related layout shift - Google Developers
To avoid layout shift, it's important to set sizes for ad elements before the ad tag loads. This can be difficult or impossible...
Read more >
Layout, Reflow Cost, and JavaScript Layout Thrashing Guideline
Layout Cost and Reflow Cost refer to the time and resource size a web browser spends while formatting, positioning, and painting web page ......
Read more >
Optimize Cumulative Layout Shift (CLS): Improving SEO with ...
In other words, the cumulative layout shift refers to the website's format changes after the browser renders it. It usually happens when dynamically...
Read more >
How CLS Score Affects Your SEO Rankings - Syntactics, Inc.
Through the Cumulative Layout Shift (CLS) – one of the Google Core Web Vitals – web designers can measure the instability of their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found