next/image decreases (lighthouse) performance
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
See below
To Reproduce
I created a couple of code sandboxes with the nextjs starter example. The first is unmodified, the second one replaces the next/image package with an img HTML element.
- Generate a lighthouse report for the version with next/image
- Generate a lighthouse report for the version with img
I'm attaching the HTML reports that I got
reports.zip
Current vs. Expected behavior
Using the native image tag is apparently more performant. However the docs and the eslint rule @next/next/no-img-element discourage this option.
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
https://codesandbox.io/docs/learn/environment/vm
Which area(s) are affected? (Select all that apply)
Image optimization (next/image, next/legacy/image)
Additional context
I first found these results in my production app, deployed on AWS Amplify. I reproduced the same result if I build the app and serve it locally. The issue is reproducible in the code sandbox as well, running the latest version of Next. It's unclear if this is an issue with Lighthouse or Next.
I tested with .svg and .png images. The priority prop doesn't seem to make a measurable difference.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two linked CodeSandbox reproductions and compare their Lighthouse HTML reports, focusing on next/image versus the native img element. Check whether the difference is caused by Lighthouse or Next.js image optimization, including the reported SVG, PNG, and priority cases. Done means the cause is established and the expected image behavior or documentation guidance is clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- frontend, performance, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100