Website Speed Optimization: The Complete Technical Guide

Why websites are slow, how to find the real cause, what to change, and how to prove the fix worked. Written to be useful whether you run a website, build them, or optimize them for clients.

How a web page actually loads

A slow website is never just "slow". It is slow at a specific stage of a sequence the browser follows every time. Find the stage and you have found the problem.

  1. DNS and connection: The browser turns your domain into an IP address, opens a connection and negotiates TLS. Usually milliseconds — but a slow DNS provider or a distant server shows up here, before a single byte of your page is sent.
  2. Server response: Your server receives the request and builds the HTML: application code, database queries, templates, API calls. The time until the first byte arrives is TTFB. Nothing the browser does next can start before this finishes.
  3. HTML parsing and resource discovery: The browser reads the HTML and finds what else it needs — stylesheets, scripts, images, fonts. Anything it cannot discover here, because a script will insert it later, is requested late.
  4. Render-blocking work: Stylesheets and synchronous scripts must be downloaded and processed before the browser will paint anything. This is why a page can be fully downloaded and still show a blank screen.
  5. First paint and largest paint: The browser paints. The moment the biggest piece of visible content finishes rendering is your Largest Contentful Paint — the metric most readers are here about.
  6. JavaScript execution: Scripts are parsed, compiled and run on the main thread. While that thread is busy, the page cannot respond to a tap or a click. This, not file size, is what makes a page feel sluggish.
  7. Layout stability: Late-arriving images, fonts and injected banners move content that has already been painted. Each shift is measured and scored as Cumulative Layout Shift.
  8. Interaction: The visitor taps something. How long until the screen updates is Interaction to Next Paint — and it depends on whatever else the main thread is doing at that moment.

The three metrics Google measures

Core Web Vitals are assessed on real visitor data, at the 75th percentile, over a rolling 28-day window. That last detail matters: a fix you ship today will not show in your assessment today.

  • LCP — Largest Contentful Paint: How long until the largest piece of visible content has rendered. Good: 2.5 seconds or less. Poor: Over 4 seconds.
  • INP — Interaction to Next Paint: How long after a tap or click until the screen visibly updates. Good: 200 milliseconds or less. Poor: Over 500 milliseconds.
  • CLS — Cumulative Layout Shift: How much visible content moves unexpectedly while the page loads. Good: 0.1 or less. Poor: Over 0.25.

Where to start when your site is slow

  1. Measure the right thing: Get field data for real visitors, then a lab test you can repeat. Two tools disagreeing about your site is normal and does not mean either is broken.
  2. Find out which stage is slow: Is the server slow to respond, or is the server fast and the browser slow to render? These have nothing in common and no shared fix. Split them before going further.
  3. Identify the specific element or script: Not "images are slow" but which image. Not "too much JavaScript" but which task, in which file, taking how many milliseconds.
  4. Prioritize by impact and effort: A one-line change that removes 800ms beats a week-long refactor that removes 200ms. Fix in that order, not in the order a report lists them.
  5. Change one thing and re-measure: Several changes at once means you learn nothing about any of them, and a regression can hide behind an improvement.
  6. Verify in the field: Lab numbers confirm the mechanism changed. Only real visitor data confirms your visitors got faster. Allow for the 28-day window.

Guides

  • Improving your PageSpeed score — What the 0–100 score is actually made of, why it changes when you have not touched anything, what moves it most, and why chasing 100 is the wrong target.
  • How to test website speed properly — Why five tools give five answers for the same page, which number to trust for which decision, and how to run a test you can repeat.
  • Why is my website slow? — A symptom-first path to your own bottleneck: for each cause, how to confirm it with a specific tool and reading before you change anything.
  • Core Web Vitals explained — What LCP, INP and CLS measure, the thresholds, why the assessment uses real visitor data over 28 days, and how the three interact.
  • Largest Contentful Paint (LCP) — Identify your LCP element, break its time into the four subparts, and fix the one that is actually costing you — each has a different solution.
  • Interaction to Next Paint (INP) — Why a page that loads fast can still feel sluggish, how to find the exact slow interaction, and why cutting bundle size often does not help.
  • Cumulative Layout Shift (CLS) — How layout shift is scored, what a session window is, which shifts do not count, and how to reserve space for everything that arrives late.
  • Passing on desktop, failing on mobile — The same URL, two verdicts. Why shrinking your images did not fix it, and why mobile is usually a CPU problem before it is a bandwidth problem.
  • Shopify speed optimization — What Shopify already optimizes for every store, what is still yours to fix, and what cannot be changed at all — so you stop paying for work already done.
  • Shopify apps, pixels and scripts — Measure what each app actually costs, attribute every request to its owner, and decide what to keep — without uninstalling the app your revenue depends on.
  • Complete website performance audit — A reusable professional methodology: scope, URL sampling, severity scoring, a defensible priority order, implementation handoff and verification.
  • Website performance glossary — Every term used across this hub, defined in plain language first, then technically — each linking to the guide that teaches it in full.
  • Website image optimization — Choose format and quality by measurement instead of by rule, find the real display size at each breakpoint, and get srcset and sizes right.
  • Lazy loading images — Where lazy loading belongs, where it actively damages LCP, and how to verify what was actually deferred.
  • JavaScript performance optimization — Download cost and execution cost are different problems with different fixes. Why halving your bundle can change nothing.
  • Third-party scripts — Inventory every external script, measure what each costs, and apply the right loading strategy — including click-to-load for chat and video.
  • CSS performance optimization — Why stylesheets block rendering, how to inline critical CSS safely, and why a Coverage report is not a delete list.
  • Web font optimization — Fonts are a loading problem and a layout-stability problem at once. Subsetting, font-display, preload, and metric-matched fallbacks.
  • Browser caching explained — Browser, server and CDN caches are three different things. Cache-Control in detail, conditional requests, and a strategy that can be invalidated.
  • GZIP vs Brotli compression — How encoding is negotiated, which file types to compress, and which to leave alone because compressing them again costs CPU for nothing.
  • TTFB optimization — Isolate which phase of the response is slow before spending money. A slow TTFB is often a redirect chain or a missing index, not your hosting.
  • CDN performance explained — How an edge request works, why cache keys cause accidental misses, and the cases where a CDN adds complexity without adding speed.
  • Website hosting performance — How to tell a resource limit from an application problem, with the measurements that justify an upgrade — or prove it would change nothing.
  • WordPress speed optimization — A safe diagnostic sequence that does not start by telling you to change your theme or delete the plugins your business runs on.
  • WooCommerce performance — Why an ecommerce site cannot be cached like a blog, and how to optimize product queries as the catalogue grows without breaking checkout.
  • Ecommerce speed optimization — Five page types, five different bottlenecks, five different priorities — and why checkout is a correctness-first zone, not a speed-first one.
  • Shopify theme performance — Which Liquid patterns are expensive and what to write instead, with the rendering cost of each shown in the Theme Inspector.
  • Shopify product page optimization — Faster product media without compromising how the product looks — image_url, image_tag, gallery loading order and click-to-play video.
  • Mobile website performance — Why mobile is a CPU problem first, what emulation does not reproduce, and how to test on a real mid-range device on a real network.
  • Continuous performance monitoring — Why optimized sites decay, and the monitoring, budgets and ownership that stop it happening again.

Reference

  • Lighthouse warnings — What each Lighthouse and PageSpeed Insights warning actually means, why it appeared on your page, whether it matters for you — several are safe to ignore — and what to change.
  • Platform permission matrix — Most performance advice assumes you control your own server. On Shopify, Wix or Squarespace you do not. This is which fixes are available to you, platform by platform — and what to do instead when one is not.
  • Performance lab — Live test pages for each performance problem, in matched pairs that differ in exactly one way, so you can reproduce our results with your own tools instead of taking our word for them.
  • How we test — The devices, networks, tools and run protocol behind every measurement we publish — so you can reproduce it, or challenge it.
  • About this hub — Who writes these guides, how they are reviewed, what makes them different, and what we will never claim.

Lighthouse warnings

Frequently asked questions

Is a PageSpeed Insights score of 100 the goal?

No. The score is a lab summary of one simulated load; Google assesses real visitor data at the 75th percentile instead. A site can score 100 in the lab and still fail Core Web Vitals for actual visitors, and a site scoring in the 70s can pass comfortably. Optimize the metrics your visitors experience, not the score.

Will making my website faster improve my Google rankings?

It can contribute, but it is one input among many and it does not override relevance. Core Web Vitals are a documented part of page experience, so performance is a genuine factor — but faster alone will not outrank a more relevant page. The dependable return on performance work is better user experience and conversion, with ranking as a possible secondary effect.

Why do PageSpeed Insights and my own Lighthouse run disagree?

Because they are measuring different things under different conditions. Field data describes your real visitors over 28 days; a lab run simulates one visit on throttled CPU and network from one location. Different test locations, cache states and even consecutive runs on the same URL produce different numbers. Both can be correct at once.

My site is fast on my computer. Why do visitors say it is slow?

You are testing on a fast desktop, on a fast connection, with your site already cached. Most visitors arrive on a mid-range phone, on a mobile network, with an empty cache. Mobile CPUs are several times slower, so the same JavaScript takes several times longer to run. Test on a real mid-range phone before concluding anything.

Do I need a developer to fix performance problems?

It depends entirely on the cause. Image sizes, unused apps and plugins, and some loading settings are often changeable without code. Server response time, database queries, render-blocking stylesheets and how your own scripts load generally need a developer. Diagnosing the cause first tells you which situation you are in — and saves paying for work that was never going to help.

Where should I start?

Measure before changing anything. Find out which stage of loading is slow, then read the guide for that stage. Applying fixes before diagnosis is why so much performance work produces no measurable result.