next.js
dbc0bef0 - docs: clarify that Image preload and fetchPriority can be combined (#102705)

Commit
2 days ago
docs: clarify that Image preload and fetchPriority can be combined (#102705) ### What? Clarifies in the `next/image` API reference (shared by App and Pages Router) how `preload` and `fetchPriority` interact: - Removes "When the `fetchPriority` property is used" from the `preload` "When not to use it" list. - States that `preload` does not set a fetch priority on its own, and that an explicit `fetchPriority` is forwarded to both the `<img>` element and the preload hint, so combining `preload` with `fetchPriority="high"` is supported. ### Why? After `priority` was deprecated in favor of `preload`, the docs listed `fetchPriority` as a reason not to use `preload`, which reads as if the two props conflict. They don't: - `preload` controls early discovery (a preload hint), not request priority. The coupling between preloading and `fetchPriority="high"` was intentionally removed in #67351, and #98754 explains why preloaded images are not automatically high priority. - When both props are set, `ImagePreload` passes `imgAttributes.fetchPriority` into the preload options (`packages/next/src/client/image-component.tsx`), and `get-img-props.ts` only warns for `preload` combined with `loading="lazy"`, not with `fetchPriority`. A reproduction on 16.4.0 and 16.5.0-canary.77 (production, Turbopack) confirmed this: `preload` alone emits no fetch-priority hint, while explicit `high` or `low` reaches both the image and the preload link. #101345 already separated discovery, eager loading, and fetch priority; this closes the remaining gap about their combination. ### How? Docs-only change to `docs/01-app/03-api-reference/02-components/image.mdx`. ### Verification - Read `ImagePreload` in `packages/next/src/client/image-component.tsx` and the dev warnings in `packages/next/src/shared/lib/get-img-props.ts` to confirm the forwarding and that no conflict warning exists for `preload` + `fetchPriority`. - `prettier@3.6.2 --check` on the changed file passed. - Not run: browser request-priority measurements; the reproduction checked emitted HTML and preload hints only. <!-- NEXT_JS_LLM --> Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
Author
Parents
Loading