From 326a8f39285883a20347e066bcaf04e06bc53a7c Mon Sep 17 00:00:00 2001 From: Anthony Lukach Date: Mon, 3 Aug 2026 09:28:23 -0700 Subject: [PATCH] perf: preconnect to cross-origin hosts on the critical path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither origin is known to the browser until late in the load: - assets.radiant.earth serves the four Berkeley Mono @font-face URLs declared in globals.css, so it is only discovered once that render-blocking stylesheet parses — 5247ms into a real-throttled 4G load. The connection handshake then starts cold. - The Ory session request to /sessions/whoami is flagged by Lighthouse as a preconnect candidate worth 272ms of LCP. crossOrigin is set on the font host only: fonts are fetched in CORS mode and need an anonymous socket, while the Ory session request is credentialed and needs a normal one. The auth hint is conditional because CONFIG.auth.api.backendUrl is empty in dev, where middleware serves auth pages locally. Refs #471 --- src/app/layout.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index d401adc6..4c17e554 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -6,6 +6,7 @@ import NextTopLoader from "nextjs-toploader"; import { IBM_Plex_Sans } from "next/font/google"; import { S3CredentialsProvider, UploadProvider } from "@/components"; import { metadata } from "./metadata"; +import { CONFIG } from "@/lib/config"; const ibmPlexSans = IBM_Plex_Sans({ subsets: ["latin"], weight: ["400", "500", "600", "700"], @@ -22,6 +23,18 @@ export default async function RootLayout({ children }: RootLayoutProps) { return ( + {/* ponytail: cross-origin hosts on the critical path. Both are discovered + late — the fonts only once globals.css parses — so the handshake + otherwise starts cold. crossOrigin on the font host only: fonts are + fetched in CORS mode, the Ory session request is credentialed. */} + + {CONFIG.auth.api.backendUrl && ( + + )}