Sikau

Web essentials · Day 12 · about 30 min

Performance basics

Fast pages, and doing less work.

Every second counts

Slow pages lose visitors — especially on phones and patchy mobile data. Google measures real experience with Core Web Vitals, and a few habits fix most problems: send less, load later, and don't do work you don't need.

What to measure, what to do

  • LCP (Largest Contentful Paint): how fast the main content appears. Aim under 2.5 s. Optimise and size your hero image; avoid render-blocking scripts.
  • INP (Interaction to Next Paint): how fast the page responds to taps. Keep JavaScript work short.
  • CLS (Cumulative Layout Shift): how much content jumps. Always give images and embeds width and height; reserve space for things that load late.
  • Load less: compress images (WebP/AVIF), loading="lazy" for images below the fold, defer on scripts.
  • Measure with Lighthouse and the Performance panel in developer tools.
function debounce(fn, ms) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), ms);
  };
}

const search = debounce((q) => console.log("Searching for", q), 200);
search("m");
search("mo");
search("mom");
search("momo");

The rest of this lesson

  • Where page time goesexplain
  • Debounce and throttleexplain
  • Which hurts CLS?predict
  • Fix for the problemmatch
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Web essentials