Skip to content

fix(perf): load the chat after the page, keep the host's markdown runtime, click-to-play YouTube in markdown - #2686

Open
michaelassraf wants to merge 5 commits into
mainfrom
fix/site-lcp
Open

michaelassraf wants to merge 5 commits into
mainfrom
fix/site-lcp

Conversation

@michaelassraf

@michaelassraf michaelassraf commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Three lib fixes behind slow first paints on every Flamingo site (CrUX rated a 180-URL blog group Poor at LCP 4.2 s).

The chat loads after the page. EmbeddableChat was lazy, but lazy starts the download the moment it mounts, so on every page the chat's code downloaded and ran beside hydration although the panel starts closed. It now loads once the page has loaded and the browser is idle (new afterPageLoad util), or at once on an open request (ask-ai:open, still held and delivered) or when the host passes open / defaultOpen.

Article images no longer download their originals. RichMarkdownRenderer mounts its own RichMarkdownRuntimeProvider, which filled every prop the caller left out with the lib defaults, replacing the host's runtime. On the hub that turned transformImageSrc into () => null, so each in-article image's 48 px size probe fell back to the full original file (170 to 470 KB each, on every markdown page). The provider now inherits the outer provider's values and uses the defaults only when there is none.

A pasted YouTube iframe is click-to-play. A raw <iframe src="https://www.youtube.com/embed/…"> in markdown passed straight through and loaded YouTube's player (about 470 KB of script) with the page. It now renders through the same Video facade as the youtube-embed fence; any other iframe gets loading="lazy". isYouTubeUrl is exported from video.tsx for this.

Measured on the hub (local production build, mobile Lighthouse, real throttling, median of 3): a blog post with a video went from 7.18 MB to 2.35 MB; a post with two article images from 2.11 MB to 1.64 MB.

Tests: new after-page-load.test.ts and rich-markdown-runtime.test.tsx; the markdown, embeds, features, chat and utils suites pass (1,552 tests). Checked in a browser against the hub: the chat opens from the header button with no preload, and the YouTube facade loads the player on click.

The hub needs a lib release with this to get these fixes; its own half is in the linked PR.

Change-Set: fix-site-lcp
ClickUp task: CU-17tkuw5xp4q Fix poor LCP (4.2s, Poor severity) across 180-URL blog group on flamingo.run

🤖 Generated with Claude Code

Change set flamingo-stack/openframe-oss-lib#2686: these pull requests are one change, reviewed together.

  • flamingo-stack/openframe-oss-lib#2686 (this pull request): fix(perf): load the chat after the page, keep the host's markdown runtime, click-to-play YouTube in markdown · open
  • …and 1 pull request not visible

Linked work

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

…'s markdown runtime, click-to-play YouTube iframes [preview:none]

EmbeddableChat loads its code once the page has loaded and the browser is idle (afterPageLoad), or at once on an open request or open/defaultOpen, instead of during hydration on every page. An inner RichMarkdownRuntimeProvider inherits the host's runtime: filling from the defaults made every in-article image's size probe download the full original. A raw YouTube iframe in markdown renders through the Video facade; other iframes load lazily.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michaelassraf

Copy link
Copy Markdown
Member Author

@github-actions

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review

Not reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened.

When it is ready:

  • Review this pull request

Or comment @flamingo-review. Add the flamingo-review-always label to review every push.

Updated 2026-10-15 02:31 UTC · workflow run

michaelassraf and others added 2 commits October 14, 2026 23:18
…; iframe snapshots gain loading=lazy [preview:none]

The markdown iframe override imported isYouTubeUrl from the video module, which the golden-parity test mocks, so the check was undefined there. It lives in utils/youtube-url.ts now, used by both. The two iframe fixtures' snapshots are updated for the intended loading="lazy"; srcdoc is still stripped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…zed poster [preview:none]

The card drew the full-size poster (a 1920x1080 file at 333x187, 126 KB) through the player's own poster image. It now asks the host's registered image resizer for 640px (its 320px box at 2x); the theater keeps the original, and a host with no resizer gets the original as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread openframe-frontend-core/src/utils/youtube-url.ts Outdated
michaelassraf and others added 2 commits October 15, 2026 00:10
…d; drop the duplicate check [preview:none]

Review: the YouTube check already existed (extractYouTubeId in features/video.tsx). The markdown iframe override uses it, utils/youtube-url.ts is deleted and video.tsx is back to main. The golden test's mock of the video module keeps the module's real helpers and replaces only the player.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s-lib into fix/site-lcp

# Conflicts:
#	openframe-frontend-core/src/components/features/walkthrough-video.tsx
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