Skip to content

fix(react): drop the preload from priority - #37

Merged
dangreen merged 1 commit into
mainfrom
fix/react-drop-preload
Sep 2, 2026
Merged

fix(react): drop the preload from priority#37
dangreen merged 1 commit into
mainfrom
fix/react-drop-preload

Conversation

@dangreen

@dangreen dangreen commented Sep 2, 2026

Copy link
Copy Markdown
Member

priority preloaded the image through preload from react-dom. Inside a Picture that is actively harmful: the preload sees only the <img>, so it requests the fallback format - the jpg - while the browser is picking an avif <source>. The page downloads the image twice, and the one that actually renders was never preloaded.

The combination is the natural one to reach for: the documented way to render is an Image inside a Picture, and the documented way to get eager loading is priority. Until now the only guard was a caution box telling people not to do it.

So the preload goes. priority sets loading="eager" and fetchpriority="high" and stops there, which is what @srcset/preact and @srcset/svelte have always done - the three components now behave identically, and priority is safe inside a Picture. A page that wants a real preload adds a <link rel="preload"> itself, pointed at the format the browser will take.

react-dom was a peer dependency for this one call and is dropped; it stays a dev dependency for the tests. The test keeps its assertions on loading and fetchpriority and loses the preload mock.

The documentation for this lands with the website: the components page drops the caution box, the "preload from react-dom" note, and the two "No preload" notes that only existed to describe the difference.

`preload` from `react-dom` knows only the `<img>`, so inside a `Picture`
it requested the fallback format while the browser was still picking a
`<source>` - the page downloaded the image twice. `priority` now sets
`loading="eager"` and `fetchpriority="high"` and nothing else, the same
as the preact and svelte components, and `react-dom` is no longer a peer dependency.
@dangreen
dangreen merged commit bb18209 into main Sep 2, 2026
7 checks passed
@dangreen
dangreen deleted the fix/react-drop-preload branch September 2, 2026 12:34
@github-actions github-actions Bot mentioned this pull request Sep 2, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 33630605412

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.02%) to 93.847%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 888
Covered Lines: 841
Line Coverage: 94.71%
Relevant Branches: 656
Covered Branches: 608
Branch Coverage: 92.68%
Branches in Coverage %: Yes
Coverage Strength: 79534.67 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants