Repository navigation
perf: hydrate the footer on scroll and mount the logo menu on demand - #2673
Conversation
The footer's link columns and newsletter form (about 120 component instances) hydrated with the rest of the page in one long task on load, though they sit below the fold on every page. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e525-9983-7071-a70a-d5ef82f1ba95
The logo's context menu hydrated a closed dropdown on every page load for a menu that only opens on right-click. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e525-9983-7071-a70a-d5ef82f1ba95
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Bundle sizeClient 1.31 MB
And 330 more routes. Largest changes in the client
Largest changes in the server
And 6 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 |
Follow-up to #2672. On load, the homepage hydrates in one long main-thread task, about 880 ms at 4× CPU slowdown, which dominates Total Blocking Time. Hydrating the page meant setting up 740 component instances in that task. Two of them didn't need to be part of it.
What changed
layouts/default.vue):<LazyAppFooter hydrate-on-visible />. The footer's link columns and newsletter form (about 120 component instances) hydrated with the page on load, on every page, though it's below the fold. Its server HTML is unchanged, so links work right away; the newsletter form becomes interactive once it scrolls into view.HeaderLogo.vue): the right-click menu on the logo mounted a closedUDropdownMenu(13 instances) on every page load. It now mounts on the first right-click and opens right away.After these two changes, 605 component instances hydrate on load instead of 740 (counted from the Vue tree on the homepage, 1280 px wide).
Evidence
Both sides built locally (
nuxt build, thennode .output/server/index.mjs),mainat e02e6bb vs this branch. Homepage, Playwright Chromium, Moto G Power profile, CPU throttled 4×, longest task read from alongtaskPerformanceObserver after load plus 5 s. 15 runs each, alternating in batches of 3:One batch on each side ran alongside a Lighthouse job, which is where the 1,100–1,300 ms outliers come from.
Lighthouse 12.6.1 mobile, performance only, same two local builds, 3 runs each:
devtools): scoreFCP and LCP don't change. Local Lighthouse FCP and LCP read 12–17 s because the orb simulates its slow network against localhost, so only the differences matter.
Checked in the same build, with no console error or hydration warning:
Details
What's left in the hydration task, and why I didn't change it:
UNavigationMenucosts about 20 instances per link. Each closedUTooltipcosts about 7 (root, trigger, popper) and renders no content. Both are visible and interactive on load.TreeRootthat users click into. It's above the fold.tailwind-variantsandtailwind-merge). Most of the rest is Vue's own hydration and patching, spread across those components.Taking the task further means rendering less on load. One option is a lighter header nav or hero tree. Another is to make Nuxt UI's class computation cheaper. Both are bigger changes than this PR.
eslintpasses on both files.ELI5
When the homepage loads, the browser has to wake up every interactive piece of it at once, and that freezes it for close to a second on a slow phone. The footer at the bottom and a hidden right-click menu on the logo no longer wake up until you need them, which takes about a fifth off that freeze.