Skip to content

perf: lazy-load MDX images - #1975

Merged
marcleblanc2 merged 2 commits into
mainfrom
marc/perf/lazy-load-images
Sep 18, 2026
Merged

marcleblanc2 merged 2 commits into
mainfrom
marc/perf/lazy-load-images

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Problem

  • ZoomableImage renders every doc image as an eager <img>, so a long page downloads every screenshot on it before first paint

Solution

  • This adds loading="lazy" so images below the fold wait until the reader scrolls near them

Verification

  • Measured on the preview deploy: /code-navigation/auto-indexing (16 images) goes from 2.8 MB of image bytes before load to 28 KB

  • Short pages are unchanged, since Chrome prefetches lazy images within ~1250 px of the viewport

  • Verified npx tsc --noEmit and npm run lint, no new warnings

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sourcegraph-docs Ignored Ignored Preview Sep 18, 2026 4:58am UTC

Request Review

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@marcleblanc2
marcleblanc2 force-pushed the marc/perf/lazy-load-images branch from 20f4f95 to 974b0fc Compare September 17, 2026 02:32
@marcleblanc2 marcleblanc2 changed the title perf: lazy-load MDX images perf: lazy-load MDX images and serve them as WebP Sep 17, 2026
@github-actions

This comment has been minimized.

@marcleblanc2
marcleblanc2 force-pushed the marc/perf/lazy-load-images branch from de39caa to 3369fd5 Compare September 18, 2026 03:01
@marcleblanc2 marcleblanc2 changed the title perf: lazy-load MDX images and serve them as WebP perf: lazy-load MDX images Sep 18, 2026
@marcleblanc2
marcleblanc2 marked this pull request as ready for review September 18, 2026 03:21
@marcleblanc2
marcleblanc2 requested a review from a team September 18, 2026 03:33
@marcleblanc2
marcleblanc2 enabled auto-merge (squash) September 18, 2026 03:34
marcleblanc2 and others added 2 commits September 17, 2026 22:58
ZoomableImage renders every doc image eagerly, so a long page downloads
every screenshot on it before first paint. loading="lazy" defers the
ones below the fold until the reader scrolls near them.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b274-3173-77ed-8f71-82301b157a16
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 force-pushed the marc/perf/lazy-load-images branch from 3369fd5 to f6911a6 Compare September 18, 2026 04:58
@marcleblanc2
marcleblanc2 merged commit 82de835 into main Sep 18, 2026
6 checks passed
@marcleblanc2
marcleblanc2 deleted the marc/perf/lazy-load-images branch September 18, 2026 04:58
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