Performance & Rendering
How browsers paint pixels, how React hydrates server output, and why milliseconds matter for user trust and search rankings.
Web Vitals
Google's Core Web Vitals — Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS) — measure real-user experience quality.
LCP tracks how quickly the main content appears; aim for under 2.5 seconds. INP replaced First Input Delay and measures responsiveness to taps and clicks; keep it under 200 ms. CLS quantifies unexpected layout shifts during load; stay below 0.1. These metrics directly influence SEO rankings and conversion rates, so they should be monitored in production via tools like Lighthouse, CrUX, or Real User Monitoring.
Hydration
The process where React attaches event listeners and state to HTML that was pre-rendered on the server, making a static page interactive.
Server-side rendering produces HTML quickly, but without hydration the page cannot respond to clicks. Hydration cost is proportional to component tree size — oversized client bundles delay Time to Interactive. React Server Components reduce hydration scope by keeping heavy logic on the server. Selective hydration and streaming further improve perceived performance on slow networks.
SSR vs SSG
Server-Side Rendering generates HTML per request; Static Site Generation pre-builds HTML at deploy time.
SSG is ideal for content that changes infrequently — blogs, marketing pages, documentation — because responses are served from a CDN with near-zero compute cost. SSR suits personalized or frequently updated data like dashboards and user-specific feeds. Next.js supports Incremental Static Regeneration (ISR) to combine both: static speed with background revalidation. Choose based on data freshness requirements and infrastructure budget.
Edge Computing
Running application logic on geographically distributed nodes close to end users rather than in a single central data center.
Edge functions (Vercel Edge, Cloudflare Workers) execute lightweight JavaScript at CDN points of presence, cutting round-trip latency for auth checks, A/B routing, and geo-personalization. They are not a replacement for full databases — keep edge logic stateless and fast. Pair edge middleware with origin APIs for data-heavy operations.
Lazy Loading
Deferring the initialization or download of resources until they are actually needed.
Images below the fold, route-level code splits, and heavy chart libraries are common lazy-load candidates. Native `loading="lazy"` on images and dynamic `import()` in React reduce initial bundle size. Balance lazy loading with layout stability — reserve space for deferred content to avoid CLS penalties.
Brotli Compression
A lossless compression algorithm that typically achieves 15–25% better ratios than GZIP for text assets.
Modern CDNs and servers negotiate Brotli automatically for HTTPS clients that support it. Pre-compress static assets at build time for maximum benefit. Brotli shines on CSS, JavaScript, and JSON; binary assets like images already use specialized codecs and should not be Brotli-compressed.
Lighthouse
An open-source auditing tool built into Chrome DevTools that scores performance, accessibility, SEO, and best practices.
Lighthouse runs in a simulated mobile environment by default, so desktop scores may differ from production. Use it in CI to catch regressions, but validate with field data (CrUX) because lab scores do not capture real network variability. Focus on actionable audits rather than chasing a perfect 100.
Tree Shaking
Dead-code elimination that removes unused exports from JavaScript bundles during the build step.
Tree shaking requires ES modules (`import`/`export`) and side-effect-free packages. Libraries marked as side-effectful in `package.json` may prevent shaking. Audit bundle analyzers regularly — a single barrel file re-exporting an entire icon library can negate shaking benefits.