Skip to content

perf(home): stop preloading the search worker and motion-v - #2672

Merged
atinux merged 2 commits into
mainfrom
perf/home-first-paint
Nov 17, 2026
Merged

atinux merged 2 commits into
mainfrom
perf/home-first-paint

Conversation

@atinux

@atinux atinux commented Nov 17, 2026

Copy link
Copy Markdown
Member

Written by an AI agent on behalf of @atinux.

Follow-up to #2656 and #2662, aimed at the homepage's render delay. The LCP element (the hero description) is in the HTML, but Lighthouse delays painting it behind every resource it counts as render-blocking: the stylesheet and every high-priority script. Two of those preloads weren't needed on load.

What changed

  • Search worker (nuxt.config.ts): nuxt-workers starts the search worker with new Worker(new URL(…)), so Vite records its bundle as an asset of the entry, and the renderer then emitted a modulepreload for it on every page. That bundle is SQLite wasm plus comark-content: 270 KB raw, 87 KB transferred, needed only once the search palette opens. A build:manifest hook clears preload and prefetch on script assets, so the worker loads when the palette first opens.
  • Features grid (index.vue): it was the homepage's only <Motion>, which made motion-v (about 130 KB raw) part of the chunks the homepage preloads. The fade-in is now a CSS keyframe applied when the section hydrates, which happens as it scrolls into view, with the same 100 ms stagger and prefers-reduced-motion respected. This also fixes a bug: <Motion> server-rendered the items with opacity: 0, so they stayed invisible until hydration.

Evidence

Homepage <head> on nuxt.com today vs this branch's local build: 105 → 103 modulepreload links, the search worker is no longer among them, and no preloaded chunk contains motion-dom. Preloaded JS goes from about 1,170 KB to 1,034 KB raw.

The search worker loads when the palette opens, not before:

before opening search: []
after opening: [ 'script search-bnTM2Vif.js' ] results 24

Both sides built locally (nuxt build, then node .output/server/index.mjs), main at 1b07618 vs this branch, Lighthouse 12.6.1 mobile, performance only, alternating runs.

Applied throttling (--throttling-method=devtools: real CPU slowdown and network shaping), 3 runs each:

main This PR
Score 29, 31, 31 34, 33, 33
FCP (median) 8.7 s 7.4 s
LCP (median) 8.8 s 7.4 s
TBT (median) 1,477 ms 1,347 ms

Simulated throttling (Lighthouse's default, which the CI lighthouse job and PageSpeed use), 5 runs each:

main This PR
Score 55, 55, 55, 55, 55 47, 48, 44, 42, 40
FCP (median) 14.9 s 12.5 s
LCP (median) 19.6 s 17.2 s
TBT (median) 0 ms 452 ms

The simulated score goes down even though the page paints earlier. FCP and LCP drop by about 2.4 s in both modes, but simulated TBT jumps from 0 to about 450 ms. That's not new work: main-thread time is about the same (4.0 s vs 4.3 s), with the same long tasks. Simulated TBT only counts long tasks between FCP and TTI. On main, the roughly 300 ms hydration task finishes before the simulated FCP and counts for 0. With FCP 2.4 s earlier, it lands inside the window. Under applied throttling, where timings aren't modelled, this PR wins on every metric. Expect the CI Lighthouse run and PageSpeed to report a lower score until that hydration task shrinks.

FCP and LCP read 15–20 s in simulated mode because Lighthouse simulates its slow network against localhost, so only the difference between the two columns matters. Lighthouse runs from this sandbox vary between runs.

Details

  • The hook clears preload and prefetch on every script asset in the client manifest, not only the search worker. Vite only lists a script as an asset for new Worker(new URL(…)) and similar URL imports, never for chunks the app imports.
  • Not changed:
    • Global stylesheet: 312 KB raw, 43 KB transferred. About a third of its rules match the homepage, but splitting Tailwind per page is a large change for that size.
    • Inline icon CSS (55 KB): 20 KB of it is the custom:rspack icon, whose SVG has 132 paths. SVGO saves 1%, and the vscode-icons Rspack icon is a different drawing.
  • Next step, to raise the simulated score as well: shrink the hydration task of about 300 ms on load, which comes from the hero and header components.
  • eslint passes on both files. The search palette still returns results, and the features grid renders fully and fades in on scroll with no console errors.

Features grid after the CSS fade-in

ELI5

Every page was downloading the search engine and an animation library before showing anything, even though you only need them when you search or scroll down. Now they wait, so the page shows up sooner. One Lighthouse mode still rates it lower, because an earlier first paint means a chunk of startup work now falls inside the window it measures.

nuxt-workers starts the search worker with new Worker(new URL(...)), so
Vite lists the bundle as an asset of the entry and the renderer preloaded
its 270 KB on every page. The palette loads it when it opens.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e525-9983-7071-a70a-d5ef82f1ba95
The features grid was the homepage's only use of <Motion>, which made
motion-v (about 130 KB) part of the chunks it preloads. It also rendered
the items with opacity 0 on the server, so they stayed invisible until
hydration.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e525-9983-7071-a70a-d5ef82f1ba95
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
nuxt Ready Ready Preview Nov 17, 2026 10:12pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The features section now reveals its feature items and CTA with a staggered CSS animation after hydration. The animation is disabled when reduced motion is preferred. A build:manifest hook now disables preload and prefetch for manifest resources whose type is script.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: Minimal · up to 6861f

This change removes two preloaded resources from the homepage and replaces a JavaScript animation with a CSS one. It has no identified functional or operational risk and is reversible with a normal code revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the homepage performance fix that stops preloading the search worker and motion-v. It is short, specific, and follows the conventional commit style. The changeset remo…
Description check Passed The description explains the purpose, the changes to nuxt.config.ts (the build:manifest hook clearing preload and prefetch on script assets) and index.vue (the CSS fade-in replacing Motion), along wit…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the homepage performance fix that stops preloading the search worker and motion-v. It is short, specific, and follows the conventional commit style. The changeset removes the search worker preload through a build:manifest hook in nuxt.config.ts and replaces the features grid Motion component with a CSS fade-in in index.vue.

Full details: Description check

Explanation

The description explains the purpose, the changes to nuxt.config.ts (the build:manifest hook clearing preload and prefetch on script assets) and index.vue (the CSS fade-in replacing Motion), along with benchmark evidence and trade-offs. It is directly related to the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

app/pages/index.vue

Parsing error: Unexpected token {

nuxt.config.ts

Parsing error: Unexpected token {

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 892da544-ea40-4fe2-82bf-4e024b9b4790
Commits

Reviewing files that changed from the base of the PR and between 08b7948 and 6861f59.

Files selected for processing: 2

  • app/pages/index.vue
  • nuxt.config.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@nuxt-com-bundle-report

Copy link
Copy Markdown

Bundle size

Explore the comparison →

Client 1.31 MB $\color{green}\textsf{(-18 B, -0.0}\%\textsf{)}$ · Server 9.15 MB $\color{green}\textsf{(-221 B, -0.0}\%\textsf{)}$

Initial page load PR Δ
/ 341.2 kB −39.7 kB (−10.4%)
Largest changes in the server
Package or file Base PR Δ
[unassigned] 7.82 MB 7.82 MB −355 B (−0.0%)
.nuxt/dist/server/_nuxt/index-styles-3.CqU7H8jN.mjs n/a 113 B +113 B
.nuxt/dist/server/_nuxt/index-styles-2.kqro8UEk.mjs 112 B n/a −112 B (−100.0%)
.nuxt/dist/server/_nuxt/HomeLogoCarousel-styles.YukJVAN3.mjs n/a 94 B +94 B
.nuxt/dist/server/_nuxt/HomeSectionContributors-styles.qc5C-uKN.mjs n/a 88 B +88 B
.nuxt/dist/server/_nuxt/slug-styles.CVjTbRKd.mjs n/a 87 B +87 B
.nuxt/dist/server/_nuxt/HomeSectionContributors-styles.CONCrYGf.mjs 87 B n/a −87 B (−100.0%)
.nuxt/dist/server/_nuxt/slug-styles.DM6jAnhr.mjs 84 B n/a −84 B (−100.0%)
.nuxt/dist/server/_nuxt/index-styles-2.umEggrSg.mjs n/a 84 B +84 B
.nuxt/dist/server/_nuxt/HomeLogoCarousel-styles.xSZZgyUD.mjs 80 B n/a −80 B (−100.0%)

And 5 more packages or files.

Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Measured by nuxt-bundle-analyzer for 6861f59.

@atinux
atinux merged commit e02e6bb into main Nov 17, 2026
18 checks passed
@atinux
atinux deleted the perf/home-first-paint branch November 17, 2026 23:00

This branch was successfully deployed

1 active deployment
Preview — 6861f599 Deployed Nov 17, 2026 by vercel[bot] via e2e #10313
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