Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103
Binaries:
Node: 16.20.0
npm: 8.19.4
Yarn: 1.22.19
pnpm: 8.6.0
Relevant Packages:
next: 13.4.13-canary.14
eslint-config-next: 13.4.11
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.6
Next.js Config:
output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
Image optimization (next/image, next/legacy/image)
Link to the code that reproduces this issue or a replay of the bug
Link to the code that reproduces this issue or a replay of the bug
https://github.com/gauravsaini964/image-preload-next13
To Reproduce
- Build the repo.
- Navigate to index page (which is using app-dir) and inspect network tab.
- Preload image is loaded twice of different resolution.
- Navigate to /page-dir (which is using page dir).
- Correct image is preloaded only once.
Generated preload tag
<link rel="preload" as="image" fetchpriority="high" imagesrcset="https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=640&quality=75 640w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=750&quality=75 750w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=828&quality=75 828w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=1080&quality=75 1080w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=1200&quality=75 1200w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=1920&quality=75 1920w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=2048&quality=75 2048w, https://staging.nathabit.in/_nat/images/face_malai_mobile_4c3ebeef79.jpg?format=auto&width=3840&quality=75 3840w" imagesizes="80vw">



Describe the Bug
I have 10 banners on a page.
Only 1st banner is LCP image hence I set priority=true on that banner.
Preload tag is generated and image is fetched of ~600-800px width which is correct size. But the image is fetched again of higher resolution immediately and this higher resolution image is rendered. Effectively negating the presence of preload tag.
This only happens in first banner.
On the remaining 9 banners, priority=false, lower and correct resolution image is used. Resolution is equal to the one fetched in preload tag.
Expected Behavior
Only one LCP image should be fetched and rendered.
Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
Vercel