Web Performance Fundamentals
Overview
Speed is a feature. This tutorial covers the fundamentals of web performance: measuring and optimising your application using Core Web Vitals, Lighthouse audits, bundle optimisation, code splitting, and lazy loading. You'll learn how to make your application faster and more responsive.
1. Performance Metrics & Core Web Vitals
Core Web Vitals are Google's standard metrics for user experience:
- LCP (Largest Contentful Paint): Loading performance. Time to render the largest content element. Target: < 2.5s.
- FID (First Input Delay): Interactivity. Time from user interaction to browser response. Target: < 100ms.
- CLS (Cumulative Layout Shift): Visual stability. Unexpected layout shifts. Target: < 0.1.
- FCP (First Contentful Paint): First content appears. Target: < 1.8s.
- TTI (Time to Interactive): Page becomes fully interactive. Target: < 5s.
2. Lighthouse Audits
Lighthouse is an open‑source tool for auditing performance, accessibility, SEO, and more. Run it in Chrome DevTools or via CLI.
Lighthouse performance categories:
- Performance: LCP, FID, CLS, FCP, TTI, TBT (Total Blocking Time).
- Accessibility: Semantic HTML, ARIA, contrast.
- Best Practices: Security, modern standards.
- SEO: Meta tags, robot rules.
- PWA: Progressive Web App capabilities.
3. Bundling & Code Splitting
Bundlers (Webpack, Vite, Rollup) combine modules into optimised bundles.
Code splitting strategies
- Route‑based: Each route loads its own chunk.
- Component‑based: Large components (modals, charts) load on demand.
- Vendor splitting: Third‑party libraries in separate bundles.