Skip to content
Guides

How to make your website faster: what to do and what to avoid

Is your website slow? Learn how to measure its speed, what really helps and what to avoid. Covers LCP, INP and CLS, with code examples.

When is a website fast?

A website is fast when its main content appears quickly, the page responds straight away when you click or type, and nothing jumps unexpectedly while you use it. Google measures this with three metrics, known as Core Web Vitals:

Metric What does a visitor notice? Good Needs improvement Poor
LCP (Largest Contentful Paint) How quickly does the largest item on screen appear, often a photo or block of text? up to 2.5 s up to 4 s over 4 s
INP (Interaction to Next Paint) How quickly do you see a response when you click, tap or type? up to 200 ms up to 500 ms over 500 ms
CLS (Cumulative Layout Shift) How much does the page move unexpectedly? up to 0.1 up to 0.25 over 0.25

These are the thresholds used by PageSpeed Insights. According to web.dev, it's best to assess them at the 75th percentile, separately for mobile and desktop. If your LCP there is 2.5 seconds, LCP was 2.5 seconds or less for at least three quarters of the page visits measured. That way, you're not just looking at the experience on a fast phone.

How important is speed for Google and AI?

Speed counts, but a fast page without a good answer won't come out on top because of speed alone. Here's what Google says about page experience:

  • Google's ranking systems use Core Web Vitals. Google highly recommends that site owners achieve good values.
  • Good results don't mean you're certain to rank at the top.
  • Google tries to show the most relevant content, even if the page experience is poorer. When there are many helpful pages, a good experience can contribute to success.
  • Chasing a perfect score just for SEO may not be the best use of your time.

In its guide to AI features in Google Search, Google also recommends a good page experience with low latency. That advice is about Google, and says nothing about how other AI assistants choose sources. Either way, a fast site is better for anyone who clicks your link.

How do you measure your website's speed?

Test a few important pages with PageSpeed Insights, look at real visitors first, then use the lab test to find the cause.

  1. Open PageSpeed Insights (pagespeed.web.dev), enter a page's URL and start the test.
  2. Check Mobile first, then Desktop.
  3. See whether there's data from real visitors at the top. It comes from Chrome and covers the past 28 days. Check whether it's about this page or your whole site, too.
  4. Then go to the lab test. It loads the page in a simulated environment and helps you find causes. A score of 90 or above is good, 50 to 89 needs improvement, and below 50 is poor.
  5. Test different types of page, such as your homepage, a service or product page and an article. Each may have a different problem.
  6. Write down the date and results. Change one thing, then measure again.

A lab test without a visitor can't measure INP, because nobody clicks or types. It does show Total Blocking Time (TBT). According to web.dev, you can use TBT as a proxy for INP in the lab, but it doesn't replace measuring real visitors.

Google Search Console also has a Core Web Vitals report, which shows how your pages perform.

What should you do?

Start with whatever slows down your most important pages the most. These eight improvements are a good place to begin.

1. Load the main image early

Is a photo at the top of the page the largest item on screen? It often determines your LCP. Put it in the HTML as a regular <img> so the browser finds it straight away. Use fetchpriority="high" to show that it's important (web.dev on LCP):

<img src="/img/bakery.webp" alt="Baker taking bread out of the oven"
     width="1200" height="800" fetchpriority="high">

Do this for no more than one or two images. According to web.dev, giving priority to more than that stops it from helping your LCP.

2. Don't make images larger than necessary

A 4,000-pixel-wide photo wastes data if it's only displayed at 800 pixels wide. Resize and compress photos, and use WebP or AVIF where you can. With srcset and sizes, the browser can choose a suitable size itself:

<img src="/img/cake-800.webp"
     srcset="/img/cake-400.webp 400w, /img/cake-800.webp 800w, /img/cake-1600.webp 1600w"
     sizes="(max-width: 800px) 100vw, 800px"
     width="800" height="600" loading="lazy" alt="Strawberry cake with whipped cream">

This example is for a photo further down the page, which is why it uses loading="lazy". Smaller files save data, but they don't always fix a slow LCP. According to web.dev, the download time of the LCP item isn't a significant bottleneck on most sites. The browser may also find the photo too late, or be unable to display it yet.

3. Give every image and video fixed dimensions

With width and height, the browser knows in advance how much space it needs, so text doesn't jump when the image appears. Keep the same proportions as the file, and use CSS to control the size on small screens:

img {
  max-width: 100%;
  height: auto;
}

Reserve space for ads, maps, videos and other items that load later too, for example with min-height or aspect-ratio (web.dev on CLS). Don't let a cookie notice or promotional bar push content down unexpectedly: reserve space for it in advance, or have it appear on top of the page. If you do that, make sure people can still use your content.

4. Load images further down the page later

Add loading="lazy" to images that aren't visible when the page opens. The browser only fetches them when the visitor gets close. Don't use it for images that are visible straight away (web.dev on lazy loading).

5. Remove scripts you don't need

Chat widgets, tracking codes, social media embeds and unused plugins can all add JavaScript. While the browser processes it, a click can take longer to have an effect (web.dev on INP). Make a list, and decide whether you really use each script.

A regular script in the <head> can delay the page from being displayed. For scripts you don't need straight away, defer is often a good choice:

<!-- Less good: the browser waits for this script -->
<script src="/js/menu.js"></script>

<!-- Often better: run it after the HTML has been processed -->
<script src="/js/menu.js" defer></script>

Then check that everything still works, especially your menu, forms, shopping basket and cookie notice. Some scripts need to load in a specific order or very early.

6. Make your CSS smaller

The browser usually waits for stylesheets in the HTML before it displays the content below them. Remove CSS you don't use, make the files smaller, and load styles you don't need straight away later. If you use a theme or page builder, turn off any features you don't use.

7. Use fewer fonts

Each font file has to be downloaded. Use only a few variants, choose WOFF2, and leave out characters you don't need if the licence allows it. The browser doesn't need to download a system font (web.dev on fonts).

font-display controls what visitors see while a font loads. With swap, text appears quickly but can shift when the font is ready. optional prevents those shifts, but some visitors won't see your custom font. Hosting your own fonts isn't always faster. It also depends on your server and whether you use a CDN.

8. Check your hosting, caching and redirects

If your server is slow to respond, everything starts later. As a rough guide, web.dev suggests a Time to First Byte (TTFB) of 0.8 seconds or less, and recommends looking at your hosting first (web.dev on TTFB).

  • Hosting: can your server handle the number of visitors, and is its software up to date?
  • Caching: can the server avoid rebuilding a page that's the same for everyone each time? Be careful with shopping baskets, accounts and other personal pages. Never show them to someone else through a shared cache.
  • CDN: do you have visitors far from your server? A CDN can store files closer to them.
  • Redirects: link straight to the correct URL, without unnecessary steps in between.

What should you avoid?

Don't change anything just to get a higher score. Some quick fixes make a page slower or harder to use.

Avoid Why? What to do instead
Loading every image with loading="lazy" The main photo starts loading too late Only use it for images outside the first screen
Adding fetchpriority="high" to everything If everything has priority, it no longer helps Use it for no more than one or two important images
Loading the main photo only through CSS or JavaScript The browser finds it later Put it in the HTML as an <img>. If you can't, load it in advance with preload
Stacking several speed plugins They can do the same thing and get in each other's way Use one, test each setting and know how to undo it
Deferring every script without checking Menus, forms or cookie consent can break Change one script at a time and test the site
Removing useful text or photos for a higher score Your visitors get a worse answer Keep what's useful and make the files smaller
Testing only your homepage Other pages can have very different problems Test each important type of page
Drawing conclusions from one lab test A lab test doesn't show what all your visitors experience Test more than once and look at real visitors where you can
Changing everything at once You won't know what helped or what broke Change one thing and measure again

Make a backup before major changes, and try them in a test environment first if you can.

Where should you start?

Start with the metric that isn't good for real visitors. If you don't have that data, use the lab test as a starting point.

What do you see? What could be causing it? First step
LCP is slow The server is slow, the main photo loads late, or CSS or scripts delay the display Check TTFB, then whether the main photo is in the HTML and isn't lazy, followed by CSS and scripts
INP is high A lot of JavaScript, heavy JavaScript or a very large page Remove unnecessary scripts and ask a developer to investigate slow interactions
CLS is high Images without dimensions, late banners or fonts being swapped Set dimensions and reserve space
TTFB is high Slow hosting, no cache or redirects Discuss the results with your hosting provider or developer

A large page can also respond more slowly, because the browser has more elements to process. Give a developer the URL, the type of device and your results. That makes it easier to find the cause than just saying "the site is slow".

Checklist

  • I've tested my most important types of page on mobile and desktop.
  • I've checked whether there's data from real visitors, and whether it's about the page or the whole site.
  • The main image at the top is in the HTML and doesn't use lazy.
  • No more than one or two images use fetchpriority="high".
  • Images aren't unnecessarily large, and have a width and height.
  • Only images further down the page use loading="lazy".
  • Space is reserved for videos, maps, ads and banners.
  • I've removed scripts, CSS and fonts I don't use.
  • I've checked hosting, caching and redirects, and personal pages aren't stored in a shared cache.
  • The menu, forms and shopping basket still work after each change.
  • I've changed one thing at a time and measured again afterwards.

The free scan checks whether your homepage uses HTTPS and how quickly it can be fetched. If a PageSpeed Insights measurement is available, your report also shows its mobile speed. Want to improve how your site is organised too? Read Site structure for SEO.

Frequently asked questions

Does my website need to score 100 in PageSpeed Insights?

No. PageSpeed Insights considers a score of 90 or above good. Google says that chasing a perfect score just for SEO may not be the best use of your time. First check whether real visitors get good Core Web Vitals, then fix what affects them most.

Why can't I see any data from real visitors?

Google doesn't have enough data about your page. This can happen if the page is new or has few visitors, for example. PageSpeed Insights then tries to show data for your whole site. If that isn't available either, use the lab test to find problems.

How soon will I see the effect of an improvement?

A new lab test can show the difference straight away. Data from real visitors covers the past 28 days, so an improvement shows up there gradually while older visits still count.

Does a fast website help you appear in AI answers?

In its guide to AI features in Google Search, Google recommends a good page experience, which includes reducing latency. It doesn't say that a particular speed score will get you into an AI answer. Think of speed as one part of a good site, alongside useful content that's easy to find.

Sources

  1. web.dev: Web Vitals
  2. Google Search Central: Understanding Core Web Vitals and Google search results
  3. Google Search Central: Understanding page experience in Google Search results
  4. Google: About PageSpeed Insights
  5. web.dev: Optimize Largest Contentful Paint
  6. web.dev: Optimize Interaction to Next Paint
  7. web.dev: Optimize Cumulative Layout Shift
  8. web.dev: Browser-level image lazy loading for the web
  9. web.dev: Best practices for fonts
  10. web.dev: Optimize Time to First Byte
  11. Google Search Central: Optimizing your website for generative AI features on Google Search

How visible is your website?

Find out for free how you score in Google and in ChatGPT, Gemini and Claude.

Start free scan

Read also