Image without priority
gets preloaded if it is set to loading="eager"
#74234
Labels
bug
Issue was opened via the bug report template.
Image (next/image)
Related to Next.js Image Optimization.
Link to the code that reproduces this issue
https://github.com/derweili/next-image-preload-test
Deployed on Vercel: https://image-preload-test.vercel.app/
To Reproduce
<Image>
tag to your page.<Image loading="eager" />
<head>
.<head>
you will find a preload link for this image<link rel="preload" as="image">
altough you didn't set thepriority
paramCurrent vs. Expected behavior
Current behavior:
When a image is set to load eager by
loading="eager"
it gets preloaded.Example:
In this example, only the first image has set
priority
while the second does not have thepriority
tag but is only set to loadingeager
.However, currently both get preloaded using a preload link.
Expected behavior
If a image is set to
loading="eager"
withoutpriority
it should not get preloaded.Only images with
priority
should get preloaded.Provide environment information
Which area(s) are affected? (Select all that apply)
Image (next/image)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
I tested app router and pages router, this issue only happens on app router, but not on pages router. On pages router, only the image with
priority
gets preloaded.I tested various versions and could replicate the issue from
[email protected]
(with react@18) to the latest canary versions15.1.1-canary.17
and[email protected]
(both with react@19).I noticed that when editing component, the wrong preload link sometimes gets removed during HMR. But when doing a hard refresh, its rendered again.
The preload link is included in the SSR response, so its no a client side rendering issue.
The text was updated successfully, but these errors were encountered: