-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEXT-811] [appDir] next/image
with priority
doesn't generate <link rel="preload" ...>
tag.
#43134
Comments
Possible solutions I have been exploring:
|
I'm seeing this as well, though I'm also seeing this with the new |
Thanks, this is currently expected, as next.js/packages/next/client/image.tsx Lines 893 to 899 in 21d7d22
@transitive-bullshit, I could not reproduce it with |
Same Issue Here. in this demo, I created new page and add Client Component to Use import Test from './child.client';
export default async function Page() {
return (
<div className="space-y-8">
<div className="space-y-4">
<h1 className="text-xl font-medium text-gray-400/80">
Next Image Test
</h1>
<Test />
</div>
</div>
);
}
// child.client.tsx
import Image from 'next/image';
const Test = () => {
return (
<div className="space-y-2">
<div className="flex space-x-2">
<Image
src="/prince-akachi-LWkFHEGpleE-unsplash.jpg"
className="rounded-full"
width={300}
height={300}
alt="User"
/>
<Image
priority
src="https://images.pexels.com/photos/45201/kitty-cat-kitten-pet-45201.jpeg?cs=srgb&dl=pexels-pixabay-45201.jpg&fm=jpg"
className="rounded-full"
width={300}
height={300}
alt="User"
/>
</div>
</div>
);
};
export default Test; in the second image, with |
Same issue here, not seeing the preload being generated. The priority prop seems to be only be removing the lazy loading portion, even though the doc says it should also preload the image. |
@balazsorban44 , regarding:
Has anything changed in this regard with all of the effort around |
next/image
with priority
doesn't generate <link rel="preload" ...>
tag.next/image
with priority
doesn't generate <link rel="preload" ...>
tag.
The latest Beta docs now include a section on Resource hints, and it looks like support for
However, when I updated to 13.3 I am not seeing these tags in the Should I create a separate repro for this? Or should we be setting these manually as shown in e.g. this comment? |
This issue is that browsers like Safari that don't support next.js/packages/next/src/client/image.tsx Lines 959 to 963 in af49d50
The new We'll likely need to fix this in React upstream first. |
App dir is now Stable but this issues remains on next 13.4.1. It drastically cripples LCP performances :( |
Also an issue here, lcp image has fetchpriority but no preload tag is generated. |
still apparent in 13.4.5 :( |
Would be nice to just simply not support srcsets until its fixed - instead of omitting the whole feature. But thats not a next feature, its a react one... Until then, i live with the errors, and use: ReactDOM.preload(url, { as: "image" as "script" }); |
Any ETA on when this fix is landing in canary? I see huge drop in LCP performance ~1 second. |
Looks like if you need it now, you can update to 13.4.9 and use getImgProps from #51205 and use that to get the generated srcset and sizes from your image and feed it into ReactDOM.preload Just wrote this without testing, but this is a simplified version of what I did in real code import Image, { unstable_getImgProps as getImgProps } from 'next/image';
import { preload } from 'react-dom';
const ImagePreload = ({imgProps}) => {
const preloadImgProps = getImgProps(imgProps);
preload(preloadImgProps.props.src, {
as: 'image',
imageSrcSet: preloadImgProps.props.srcSet,
imageSizes: imgProps.sizes
});
return (
<Image {...imgProps} />
);
}; But looks like its almost fixed anyways with this PR #52425 |
- Depends on facebook/react#27096 - Fixes #43134 - Closes NEXT-811 - Closes NEXT-846
Please check #52995 . |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
Binaries:
Node: 18.10.0
npm: 8.19.2
Yarn: 1.22.19
pnpm: 7.13.0
Relevant packages:
next: 13.0.5-canary.2
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using
pages
directory, the<Image />
component fromnext/image
withpriority
prop will generate a<link rel="preload" as="image" ... />
on the<head />
. But this is not the case when usingapp
directory.I believe this is because, currently, the
<link>
tag is injected usingnext/head
on a client component (reference). This doesn't work given the server component setup.Expected Behavior
<link rel="preload" as="image" ... />
will also be generated for priority<Image />
when usingapp
directory.Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://github.com/kvnang/next-image-preload
To Reproduce
Under
/app/page.tsx
, the<Image />
component with srcvercel.svg
has apriority
prop set totrue
, and thus should produce<link rel="preload" />
tag. But it doesn't in this case.NEXT-811
The text was updated successfully, but these errors were encountered: