Profiling with Lighthouse and DevTools

Diagnose performance problems methodically with Lighthouse, the Performance and Network panels, and CPU and network throttling.

Intermediate · about 3 hours · difficulty 3/5

Learn first: JavaScript Loading and Runtime Performance, Images, Fonts and Critical Rendering Path

Optimising without measuring is guessing. Browser DevTools show exactly where time goes, if you know where to look.

Lighthouse

Run it from DevTools or PageSpeed Insights for an audit of performance, accessibility, SEO and best practices. Treat the score as a signal and read the opportunities and diagnostics: render-blocking resources, unused JavaScript, image sizing, LCP element. Always test in an incognito window (extensions distort results) with mobile emulation and throttling, because your laptop is not your users' phone. lighthouse-ci can run it on every pull request.

Network panel

Waterfall of every request: timing breakdown (DNS, connect, TTFB, download), sizes (transferred vs resource), caching status and priority. Look for long request chains, large files and missing compression. Throttle to "Fast 4G" or "Slow 4G".

Performance panel

Record a page load or an interaction:

  • The main thread flame chart shows long tasks (red corners), scripting, style recalculation, layout and paint.
  • Screenshots and the timings track show when LCP happens and which element it is.
  • Layout shifts are highlighted with the elements that moved.
  • CPU throttling (4x or 6x slowdown) approximates mid-range phones.

The live metrics view shows LCP, INP and CLS as you interact.

Framework tools

React DevTools Profiler for component render costs, and bundle analysers for what is shipped.

A method

Measure, form one hypothesis, change one thing, measure again. Keep notes so you know which change helped.

Good enough to move on

You can record a trace of a slow interaction, point to the long task and the code responsible, and explain every major item in a Lighthouse report.

Key concepts

  • Lighthouse audits and opportunities
  • Network panel waterfall
  • Performance panel and flame charts
  • CPU and network throttling
  • Finding long tasks and layout shifts
  • Lighthouse CI
  • Measure, change, re-measure method

Mini project

Pick a slow interaction in one of your apps, record a Performance trace with 4x CPU throttling, identify the responsible code, fix it, and write a short before/after report with screenshots of both traces.

Check yourself

Why should you run Lighthouse in an incognito window with throttling instead of a normal browser tab on your laptop?

Free resources