Most slow pages have one or two large causes. Here is how I find them before changing any code.

When someone says a site feels slow, the first instinct is to start optimising code. I try not to. A page that takes six seconds usually has one or two large causes, and a few minutes of measuring finds them.

Start with the weight

Open the network panel, reload with the cache disabled and sort by size. On most sites I look at, a handful of images account for more than half of the bytes. Fixing those is often worth more than anything I could do in JavaScript.

Then look at what blocks the page

Scripts in the head and large stylesheets stop the browser from drawing anything. You can list what the browser reported with a few lines in the console:

const [nav] = performance.getEntriesByType("navigation");
console.log("first byte:", Math.round(nav.responseStart), "ms");
console.log("page loaded:", Math.round(nav.loadEventEnd), "ms");

for (const r of performance.getEntriesByType("resource")) {
  if (r.transferSize > 200_000) {
    console.log(Math.round(r.transferSize / 1024) + " KB", r.name);
  }
}

The second loop prints every file over 200 KB. It is crude, and it is usually enough to name the culprits.

Change one thing, then measure again

I fix the biggest cause, reload and compare. If the number did not move, I undo the change. It keeps the code small and it keeps the claims honest.