Repository navigation
fix: hold back a lazy image's sources until it is visible - #21
Merged
Merged
Conversation
commit: |
lxsmnsyc
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A lazy
SolidImagedownloads one of its variants before it scrolls into view. The framework-compare SolidStart port test caught it: an image 2400px below the fold made one AVIF request before any scrolling.The server rendered the
<source srcset>tags inside<picture>for every image, and only swapped the lazy<img>for a blank SVG. The browser selects a picture's image from its<source>elements first, so it fetched the chosen variant as soon as the page was parsed, whatever the<img>pointed at.The sources now render under the same
visible()condition as the real<img>: when the image is eager or has entered the observer's root margin. On the server a lazy image is never visible, so the server and the first client render agree and hydration is unchanged. Eager images still render their sources on the server.Three existing server tests that assert on
<source>attributes now passeager, since a lazy image no longer has sources in the server HTML.Verification
pnpm test: 211 tests pass (node and Chromium browser projects).main:pnpm buildandtsc --noEmitpass.Not checked in a hydrated SolidStart app.
Left open
When the component renders only in the browser, with no server render, the
<noscript>fallback<img>is a live element with asrcset. Chrome can then fetch the fallback-format variant early if the image is within its lazy-load distance. This change does not touch that.🤖 Generated with Claude Code