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.

Handling images that have loading="lazy" for the defer offscreen images audit

See original GitHub issue

Provide the steps to reproduce

  1. Run LH on https://pr34900-985c0b4.ngbuilds.io/

What is the current behavior?

Lighthouse flags images below the fold that can be deferred.

What is the expected behavior?

Lighthouse doesn’t flag images that are below the fold and have loading="lazy" or suggests to use a custom solution that is less conservative.

More info

The native lazy loading implementation in Chrome, which uses IntersectionObserver, will only defer images that are at least 3000px from the viewport. Images that are below the fold but within this threshold load eagerly, and Lighthouse still flags those images as capable of being deferred.

Should Lighthouse follow similar heuristics to Chrome and not flag any images with loading="lazy" even if they aren’t actually deferred? Or should we consider modifying the audit recommendation to suggest that an even more conservative lazy-loading approach should be used?

Related issues

#6677

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
paulirishcommented, Mar 4, 2020

there is no 5.7.0 yet. 😃

but yeah our fix for this is in master but isn’t in 5.6.0.

i just ran both on @housseindjirdeh’s URL and see that 5.6.0 reported these images despite have loading attribute. and master doesn’t.

so this is indeed fixed. 😃

1reaction
connorjclarkcommented, Mar 27, 2020

there is no 5.7.0 yet. 😃

CDT is 5.7.1. 5.7 is just CDT (added pub ads plugin)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Defer Offscreen Images (With and Without Plugins)
Google recommends to “Consider lazy-loading offscreen and hidden images after all critical resources have finished loading to lower time to interactive”.
Read more >
Fix Defer offscreen images lighthouse warning
This usually causes a delay in page rendering. Fix this lighthouse warning by deferring images either with native lazy loading or a custom...
Read more >
Lighthouse: Defer offscreen images - GTmetrix
Deferring offscreen images (or lazy-loading) refers to the practice of delaying the loading of images that aren't in your visitors' viewport until they...
Read more >
Defer offscreen images - Chrome Developers
Install a Drupal module that can lazy load images. Such modules provide the ability to defer any offscreen images to improve performance. # ......
Read more >
Lighthouse Optimizations - How to Defer Offscreen Images
In other browsers, the loading=lazy attribute is used. JavaScript handlers can also be used for images that are dynamically added to the page...
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