Online admissions open for the SEO, web development and networking & cybersecurity courses. Enquire for the next batch.

Web Performance: How to Make Websites Load and Respond Faster

5 min read Updated By the SkillNewton team

What is web performance?

Web performance is how quickly a page loads, becomes usable and responds to visitors, and how stable it stays while loading. Improving it means sending fewer and smaller bytes, sending them sooner and doing less work in the browser. Google measures real-user experience with Core Web Vitals: LCP for loading, INP for responsiveness and CLS for visual stability.

Key metrics and terms

MetricWhat it measures"Good" threshold
LCP (Largest Contentful Paint)When the largest image or text block in the viewport is rendered2.5 seconds or less
INP (Interaction to Next Paint)How quickly the page visually responds to clicks, taps and key presses200 milliseconds or less
CLS (Cumulative Layout Shift)How much visible content jumps around unexpectedly0.1 or less
TTFB (Time to First Byte)How long the server takes to start respondingDiagnostic, not a Core Web Vital

Google assesses each metric at the 75th percentile of real page loads. INP replaced First Input Delay in March 2024. The SEO side of these metrics is covered in Core Web Vitals explained.

Lab data comes from a simulated test on one device; field data comes from real visitors. Field data is what Google uses, and lab data is what you use to debug.

Optimising images

Images are often the heaviest part of a page and frequently the LCP element. Four habits fix most image problems:

  • Use modern formats: WebP and AVIF are usually much smaller than JPEG or PNG at similar quality, and all current major browsers support both.
  • Serve the right size: use srcset and sizes so a phone does not download a desktop-sized image.
  • Always set width and height: the browser reserves the space before the file arrives, which prevents layout shift.
  • Lazy load images below the fold with loading="lazy", but never the LCP image; give that one fetchpriority="high" instead.
<!-- Hero image: the likely LCP element, loaded early -->
<img src="/img/hero-800.avif"
     srcset="/img/hero-400.avif 400w, /img/hero-800.avif 800w, /img/hero-1600.avif 1600w"
     sizes="(max-width: 600px) 100vw, 800px"
     width="800" height="450" alt="Students reviewing code on a laptop"
     fetchpriority="high">

<!-- Further down the page: lazy loaded -->
<img src="/img/team.webp" width="600" height="400" alt="Team photo" loading="lazy">

Caching headers and compression

The Cache-Control header tells browsers and CDNs how long they may reuse a response. Give static files a version in the file name or query string (for example app.3f9a1c.css) so you can cache them for a year and still ship updates instantly. HTML should be revalidated so visitors see new content.

# Nginx: long cache for versioned assets, revalidate HTML
location ~* \.(css|js|woff2|avif|webp|png|jpg|svg)$ {
    add_header Cache-Control "public, max-age=31536000, immutable";
}
location / {
    add_header Cache-Control "no-cache";
    try_files $uri $uri/ /index.php?$query_string;
}

gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;

Compression shrinks text files such as HTML, CSS, JavaScript, JSON and SVG. Gzip is universally supported; Brotli usually compresses text further and is supported by all modern browsers over HTTPS. Do not compress JPEG, WebP or AVIF again, since they are already compressed.

On the server side, a slow TTFB usually points to uncached database queries, missing OPcache for PHP or an overloaded host. Cache expensive query results, add indexes to columns used in WHERE clauses, and consider full-page caching for pages that are the same for every visitor.

Critical CSS and JavaScript deferral

By default, stylesheets in the head block rendering, and classic scripts block HTML parsing. To reach a fast first render:

  • Inline the small amount of critical CSS needed for above-the-fold content, and load the rest normally. Keep the inlined part small, as it is not cached separately.
  • Add defer to scripts that need the DOM; they download in parallel and run in order after parsing. Module scripts (type="module") are deferred automatically.
  • Use async only for independent scripts, such as some analytics tags, because async scripts run as soon as they arrive, in any order.
  • Ship less JavaScript: remove unused libraries and split code so each page loads only what it needs. Long tasks on the main thread are the usual cause of poor INP; see handling events efficiently.
<head>
  <style>/* critical CSS: header, hero, fonts */</style>
  <link rel="stylesheet" href="/css/site.3f9a1c.css">
  <script src="/js/app.8b2d4e.js" defer></script>
</head>

Measuring with Lighthouse, PageSpeed Insights and CrUX

ToolData typeUse it for
Lighthouse (Chrome DevTools)LabDebugging a page locally with a list of specific opportunities
PageSpeed InsightsField (from CrUX) and lab (Lighthouse)Checking real-user Core Web Vitals and a Lighthouse audit for any public URL
Chrome UX Report (CrUX)FieldReal Chrome user data over a rolling 28-day window, by URL or origin
Search Console Core Web Vitals reportFieldGroups of URLs that need work across the whole site

Lighthouse cannot measure INP because it does not click anything; it reports Total Blocking Time as a lab stand-in. Use the DevTools Performance panel to record real interactions. Low-traffic pages may have no CrUX data at all, in which case rely on lab tests.

Practical exercise: improve one page and measure the change

  1. Run Lighthouse in an incognito window on a page you own and note LCP, CLS, Total Blocking Time and the LCP element.
  2. Convert the largest images to WebP or AVIF, add width and height to every img, and lazy load images below the fold only.
  3. Add defer to scripts in the head and remove one script the page does not need.
  4. Set long Cache-Control headers for versioned assets and confirm compression in the Network panel (look for content-encoding: br or gzip).
  5. Run Lighthouse again three times and compare the median result with your first run.

Write down each change and its effect. Fast pages also support responsive design on slow mobile connections. The Technical SEO course connects these fixes to search performance.

Common mistakes

  • Lazy loading the hero image, which delays the LCP element instead of speeding it up.
  • Leaving out image width and height, which causes layout shift as images load.
  • Judging speed from one Lighthouse run on a fast laptop instead of field data and repeated tests.
  • Caching unversioned CSS and JavaScript for a year, so visitors keep old files after a release.
  • Adding more third-party scripts without measuring their effect on INP.

Frequently asked questions

Why do my Lighthouse score and field data disagree?

Lighthouse simulates one device and network once, while field data reflects real visitors on many devices over 28 days. Treat field data as the truth and Lighthouse as a debugging tool.

Is a perfect Lighthouse score necessary?

No. Aim for the "good" thresholds on real-user Core Web Vitals. A score is a lab summary, and chasing the last few points often brings little benefit to visitors.

Does a CDN make a website faster?

A CDN serves cached files from locations nearer to visitors, which usually lowers latency for static assets and, if HTML is cached, for pages too. It does not fix heavy JavaScript or unoptimised images.

Want to Learn This Properly?

The Technical SEO & Website Optimization (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

Protected by reCAPTCHA. Google Privacy and Terms apply.

We reply by email or phone within working hours. No spam.