Skip to content

Public sites perf · Phase 1: page weight (server-rendered blocks, lazy chat, images, fonts) #71

Closed

Description

@clbotdev

Part of the public-site performance plan (master issue linked above). Needs no CDN or new infrastructure.

Goal

Reduce how much JavaScript and how many bytes each public page sends, so LCP, INP and CLS improve whatever the TTFB.

Tasks

  • Record a baseline first: Lighthouse on a sample tenant (home, docs page, blog post) plus server-side TTFB, so each change below can be measured.
  • Render pages with server components. (Improve public site rendering performance #78) Today packages/page-builder/scripts/add-use-client.mjs marks every built file "use client", and src/renderer/page-renderer.tsx and apps/sites/components/site-page-renderer.tsx are client components, so the whole layout JSON and every block ship to the browser and run there.
    • Add a renderer entry that works on the server. Static blocks render on the server; only interactive blocks (FAQ, marquee, forms, theme mode switcher, docs search) stay client components.
    • Exclude that entry from the post-build "use client" step. The builder entry used by apps/web stays fully client.
    • Move theme resolution (resolveSiteTheme) out of the client wrapper.
  • Lazy-load the chat widget (Improve public site rendering performance #78) (apps/sites/app/sites/[teamId]/layout.tsx): render only the launcher button; load the panel when the browser is idle or on first interaction.
  • Images: (Improve public site rendering performance #78; article/feed images in perf(sites): optimize article and feed images; record Phase 1 measurements (#71) #142) use next/image (built-in optimizer) for MediaLit images, with width/height, lazy loading below the fold, and fetchpriority="high" on the hero/LCP image. Leave room for a configurable loader later (IMAGE_LOADER).
  • Lock down images.remotePatterns (Improve public site rendering performance #78, IMAGE_REMOTE_HOSTS) in apps/sites/next.config.mjs. It is hostname: "**" today, which makes the optimizer an open image proxy; limit it to the media host(s).
  • Preload the active theme fonts only. (Improve public site rendering performance #78) Fonts are self-hosted with preload: false (apps/sites/lib/fonts.ts); add <link rel="preload"> for the fonts the active theme uses.
  • Code injection: (Improve public site rendering performance #78, injected when idle) make sure tenant codeInjectionHead/Body scripts don't block rendering (defer where possible).

Done when

  • Lighthouse and Web Vitals are measurably better than the baseline on the sample tenant.
  • The editor preview in apps/web still works unchanged.

Activity

  1. clbotdev commented on Oct 19, 2026

    @clbotdev
    ContributorAuthor

    Preconnect for media origins (local Lighthouse on sendlit.app, 19 Oct, 4 mobile runs): the homepage loads an above-the-fold image from cdn.medialit.cloud, but the page has no <link rel="preconnect"> for that origin, which Lighthouse estimates costs about 300 ms on mobile.

    Proposal: when rendering a page, collect the origins of images and media used in the first blocks (hero, first section) and the site's configured media CDN, then emit preconnect (plus dns-prefetch as a fallback) in the head automatically. This should be general for any hosted customer and any media host, not hard-coded to MediaLit.

  2. s3rot0n1n commented on Oct 25, 2026

    @s3rot0n1n
    Contributor
  3. clbotdev commented on Oct 25, 2026

    @clbotdev
    ContributorAuthor

    Baseline and results recorded (Lighthouse 13, mobile, simulated throttling, median of 5, same sample tenant). The full table is in #142.

    • Performance score: home 55 → 91, docs 73 → 93, blog post 69 → 90
    • TBT: 1081–1321 ms → 144–227 ms
    • JS: 643 KB → 192 KB; home transfer 996 KB → 399 KB
    • Home LCP: 5.9 s → 3.4 s; CLS 0

    #142 also fixes article and feed images that still served full-size originals: blog post image bytes 172 KB → 44 KB.

    The editor preview in apps/web is unchanged; #142 only touches the server Image primitive and the sites app.

  4. added a commit that references this issue on Oct 25, 2026
  5. clbotdev commented on Oct 25, 2026

    @clbotdev
    ContributorAuthor

    Done: #78 (implementation) and #142 (article/feed images). Measurements in #142 and in this issue's comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions