Skip to content

Load top-of-page video thumbnails eagerly to fix mobile LCP - #5827

Open
Duncanma wants to merge 2 commits into
mainfrom
duncan/admiring-chandrasekhar-f68911
Open

Duncanma wants to merge 2 commits into
mainfrom
duncan/admiring-chandrasekhar-f68911

Conversation

@Duncanma

Copy link
Copy Markdown
Contributor

What

Adds an opt-in priority prop to the Video component and sets it on the three videos that are visible without scrolling on a phone.

The click-to-play facade hard-coded loading="lazy" on its YouTube thumbnail. A PageSpeed baseline found that on /workflows that thumbnail is the mobile LCP element, with lab mobile LCP of 4.8–13 s against ~1.1 s on other pages. A lazy image can't start downloading until layout runs, so the LCP request was delayed. Field p75 LCP for the page is 1.45 s, so the lab overstates it, but a lazy LCP image is a known anti-pattern.

With priority:

  • The thumbnail gets loading="eager" and fetchpriority="high". React 19 also hoists <link rel="preload" as="image" fetchpriority="high"> for it into <head>.
  • The page preconnects to https://i.ytimg.com.

Without it, the thumbnail stays lazy, so videos further down a page don't compete for bandwidth. The <img> now has width={480} height={360} (the fixed size of hqdefault.jpg). .aspectBox still sizes the rendered image.

Which videos got priority

Measured with the built site at 412×823, the Lighthouse mobile viewport:

Page Video top (px) priority
/workflows 712 yes
/ai/featured/agent-gateway-nexus 314 yes
/ai/featured/memory-state-stripe 282 yes
/evaluate/why-temporal 911 no
/activities 937 no
/production-deployment/worker-deployments/worker-versioning 1303 no
/temporal 1568 no

readme/COMPONENTS.md documents the new prop. The LLM Markdown pipeline ignores it (it reads only videoId and title), and tests/test-mdx-to-md.mjs passes.

Verification

  • yarn build passes. Built /workflows HTML has the eager, high-priority <img>, the preconnect, and the image preload in <head>.
  • Vale (.vale-ci.ini) is clean on the changed docs pages.
  • A PageSpeed before/after on the preview deployment is still to come.

The Video facade hard-coded loading="lazy" on its YouTube thumbnail. On
/workflows that thumbnail is the mobile LCP element, so LCP waited for
layout before the image request even started (lab mobile LCP 4.8-13 s
against ~1.1 s on other pages).

Add an opt-in priority prop. When set, the thumbnail loads eagerly with
fetchpriority="high" (React 19 also hoists a matching image preload into
<head>) and the page preconnects to i.ytimg.com. The default stays lazy so
videos further down a page don't compete for bandwidth. The img now
carries width/height for its intrinsic 480x360 size.

Set priority on the three videos that start inside the first screen at
412x823: /workflows and the two AI featured pages. The other four start
911-1568 px down and stay lazy.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
temporal-documentation Ready Ready Preview Nov 29, 2026 6:41pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs PR preview links

@Duncanma
Duncanma marked this pull request as ready for review November 29, 2026 18:40
@Duncanma
Duncanma requested a review from a team as a code owner November 29, 2026 18:40
Copilot AI balanced review requested due to automatic review settings November 29, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the opt-in video thumbnail priority-loading change.

No open issues 🎉

What changed in this PR

Adds opt-in priority loading to video thumbnails to reduce mobile Largest Contentful Paint delays, while keeping other videos lazy-loaded.

Changes:

  • Adds a priority prop for eager, high-priority thumbnail loading and a YouTube image-host preconnect.
  • Sets explicit thumbnail dimensions and enables priority loading on three selected pages.
  • Documents when and how to use the new prop.
File Description
src/​components/​elements/​Video/​Video.tsx Adds priority loading, preconnect, and thumbnail dimensions.
readme/​COMPONENTS.md Documents the priority prop and usage guidance.
docs/​encyclopedia/​workflow/​workflow-overview.mdx Prioritizes the Workflow overview video thumbnail.
docs/​ai/​featured/​memory-state-stripe.mdx Prioritizes the Agent Memory & State video thumbnail.
docs/​ai/​featured/​agent-gateway-nexus.mdx Prioritizes the Agent Gateway & Nexus video thumbnail.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
Preview — b84132ff Deployed Nov 29, 2026 by vercel[bot]
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