Skip to content

fix: do not prefetch external sidebar links - #1978

Draft
marcleblanc2 wants to merge 1 commit into
marc/perf/sidebar-prefetchfrom
marc/fix/external-nav-links
Draft

marcleblanc2 wants to merge 1 commit into
marc/perf/sidebar-prefetchfrom
marc/fix/external-nav-links

Conversation

@marcleblanc2

Copy link
Copy Markdown
Contributor

Stacked on #1976 (marc/perf/sidebar-prefetch); retarget to main once that merges.

Problem

navigation.ts has Pricing and Changelog entries with href: 'https://sourcegraph.com/...'. next/link treats an absolute URL on the current origin as an app route, so every page load prefetched the marketing pricing page (65 KB of HTML in the HAR). On versioned docs, prependVersion also turns them into /v/<version>/https://sourcegraph.com/pricing.

Fix

  • NavigationLink renders a plain <a> for any http(s):// href.
  • prependVersion only prefixes paths that start with /.

Verification

tsc, pnpm lint, pnpm build clean. On the preview, the Network tab should show no request to sourcegraph.com/pricing on page load, and the Pricing link should still navigate.

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 17, 2026 2:34am UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

The Pricing and Changelog entries point at https://sourcegraph.com/...,
which next/link treats as an app route on our own origin, so every page
load prefetched the marketing pricing page (65 KB of HTML). Render those
as plain anchors, and stop prependVersion from turning them into
/v/<version>/https://... on versioned docs.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ac9d-704f-73fe-8211-1b3e5840969f
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 force-pushed the marc/perf/sidebar-prefetch branch from e46d73d to 32ea28e Compare September 17, 2026 02:32
@marcleblanc2
marcleblanc2 force-pushed the marc/fix/external-nav-links branch from 4c29c24 to 89821fa Compare September 17, 2026 02:32
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Spell check found 1 issue(s) in this PR

Only findings on lines added by this PR, and in its title and description, are shown.

Pull request description

  • line 1, column 50
    • retargetretarded

Please correct the spelling, or add words which are correct to cspell-allow-list.txt.

Run npx cspell@10 --no-progress --dot '**/*' locally to check the full repository.

@marcleblanc2

Copy link
Copy Markdown
Contributor Author

From the docs site audit (crawl of all 502 pages).

Same root cause, one more instance outside this PR's files: the Changelog link in the desktop header (src/components/Layout.tsx:78) and mobile navigation (src/components/MobileNavigation.tsx:111) is also a next/link to https://sourcegraph.com/changelog. In the crawl that prefetch cost about 61 requests / ~500 KB per docs page and produced 1,155 "resource was preloaded but not used" console warnings. #2002 applies the same plain-<a> treatment to those two links.

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.

1 participant