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.

Images should have height and width properties according to Lighthouse

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64
Binaries:
  Node: 18.7.0
  npm: 8.15.0
  Yarn: 1.22.5
  pnpm: 7.8.0
Relevant packages:
  next: 12.2.4-canary.12
  eslint-config-next: 12.2.2
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

CodeSandbox

Describe the Bug

I’m experiencing the same issues as described in the below two tickets. The Lighthouse Performance test suite is giving me the error of Image elements do not have explicit width and height when using next/image.

https://github.com/vercel/next.js/issues/35091

https://github.com/vercel/next.js/issues/35953

Expected Behavior

I expect for Lighthouse’s Performance test suite not to give me this error when using Next’s Image component.

Link to reproduction

https://codesandbox.io/s/next-image-issue-ekqqgh?file=/pages/index.tsx

To Reproduce

Utilize Next’s Image component and run Lighthouse’s Performance suite on Chrome. You can also just see the issue in the supplied Codesandbox (Open In New Tab).

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
styflecommented, Aug 27, 2022
1reaction
pjawscommented, Aug 26, 2022

We are experiencing this issue in LHCI with PNG/JPG images as well. Testing in production mode.

Turning off uses-responsive-images to get the tests to pass doesn’t seem like a great long-term solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Lighthouse says image elements lack width and height ...
Image elements have explicit width and height​​ Set an explicit width and height on image elements to reduce layout shifts and improve CLS....
Read more >
Quick Tips: How to fix "Image elements do not have explicit ...
Option 1 - define the width and height of the image using the width and height attributes. The first option is to define...
Read more >
Properly size images - Chrome Developers
The Opportunities section of your Lighthouse report lists all images in your page that aren't appropriately sized, along with the potential ...
Read more >
Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >
Lighthouse on Twitter: "Tip: Add width & height attributes ...
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
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