A 100 on PageSpeed Insights is one of those things people like to show off. But what matters isn’t the number: it’s that the website loads fast on your customers’ phones, with normal coverage and without content jumping around.
Astro is one of the frameworks that makes this easiest, because it generates static pages and doesn’t send JavaScript unless you ask for it. Even so, there are a few things you need to get right. Here they are.
What PageSpeed Insights measures
PageSpeed Insights shows two kinds of data, and it’s best not to mix them up:
- Lab data: a test that Lighthouse runs there and then, simulating a mid-range phone on a mobile network. This is where the score from 0 to 100 comes from.
- Real user data: what visitors using Chrome have experienced over the last 28 days. This is where the Core Web Vitals are.
The Core Web Vitals are three metrics. According to Google, they’re considered good when 75% of visits meet these thresholds:
- LCP (how long the largest element takes to appear): 2.5 seconds or less.
- INP (how long the page takes to react when you tap something): 200 milliseconds or less. It replaced FID in March 2024.
- CLS (how much the content moves around while it loads): 0.1 or less.
The lab score, on the other hand, is calculated from five Lighthouse metrics: FCP, Speed Index, LCP, Total Blocking Time (the one with the most weight) and CLS. In the lab nobody is tapping the page, so instead of INP it measures how long the browser is blocked.
Start with a static website
The first thing that makes an Astro website fast is that it doesn’t have to think when someone visits: the pages are already built in HTML.
- Generate the website as static whenever you can. A form or a search box doesn’t mean the whole website has to become dynamic.
- Avoid “islands” you don’t need. Astro doesn’t send JavaScript by default: it only does so when you add an interactive component with a
client:*directive. If a carousel can be a row of photos, photos are better. - When you do need interactivity, load it late:
client:visiblewaits until the component appears on screen andclient:idleuntil the browser is free.
Images: AVIF, WebP and sizes
Images are the most common cause of a slow LCP. Astro gives you the tools in astro:assets:
- Use
<Picture />with modern formats:formats={['avif', 'webp']}. The browser picks the lightest one it understands. - Generate several sizes with
widthsandsizes. A phone shouldn’t have to download a photo 1,920 px wide. - Let Astro set the width and height. That way the browser reserves the space and the content doesn’t jump (CLS).
- Prioritise the main image. Give the large photo at the top
priority: it loads first instead of waiting. Leave lazy loading for the rest. - Prepare your images beforehand: a photo straight from a phone is much bigger than the website needs. Crop it and shrink it before uploading it.
Local fonts and few variants
Google Fonts loaded from Google’s servers add an extra connection and delay the text.
- Serve them from your own website. Packages such as Fontsource install them with npm and Astro includes them in the build.
- Use the WOFF2 format and only the weights you actually use. One variable font is better than six files.
- Make the text visible from the start with
font-display: swap, and preload only the font for the main text.
You also gain on privacy: the visitor’s browser doesn’t connect to another server to download the font.
CSS, third-party scripts and what you don’t need
- Critical CSS: Astro bundles each page’s styles and can inline the small ones in the HTML (the
build.inlineStylesheetsoption). Write styles per component and don’t load a whole CSS framework to use three classes. - No heavy “plugins”: Astro’s advantage over many content management systems is that there are no themes or plugins adding code to every page. Don’t spoil it with libraries you don’t need.
- Be careful with third-party scripts: chat widgets, embedded maps, videos, advertising pixels. Each one costs you. Load videos with a cover image and only load the player on click, and use a link or an image for the map if it doesn’t need to move.
- Animations in moderation. If you use animation libraries, check in PageSpeed that they don’t block the browser while loading.
Hosting with a CDN
The lightest website is still slow if the server responds slowly.
- Publish the website on hosting with a CDN (Cloudflare, Netlify, Vercel and similar): pages are served from a server close to the visitor.
- Set up long caching for images, fonts and files with a unique name (Astro adds a fingerprint to their names when it builds).
- Check that the server sends files compressed.
A lab 100 isn’t the same as real life
A 100 on PageSpeed is a good sign, but it has limits:
- It’s a test at one moment. The score changes from one test to the next depending on the network and the server. Run three or four and look at what repeats.
- It measures one page, not the website. Test a service page, the blog and the contact page too.
- Real data is what counts. What Google takes into account for page experience is real user data, not the lab score. On websites with few visits, PageSpeed may not have real data yet: that’s normal.
- A fast website doesn’t guarantee rankings. It helps people stay, but content is still what matters most on Google.
An example of all this is the website of Roger Catà, an agricultural consultant: built with Astro, it scored 100 on PageSpeed. Not thanks to any trick, but by applying these rules from day one.
If you want a website like that for your business, see how we work on a corporate website.
Frequently asked questions
Why does PageSpeed give me a different score every time?
Because the test depends on conditions that change: the network, the server, the machine running it. Run several tests and look at the trend, not at a single number.
Will a 100 on PageSpeed help me rank higher on Google?
Not on its own. Google takes page experience into account, but content that answers the search well matters much more. A fast website helps; it does not guarantee rankings.
Why can't I see real user data in PageSpeed?
Because Google only shows it when your website gets enough visits from Chrome users. On small or new websites it's normal to have lab data only.
Can you get 100 with WordPress?
You can, but it's harder: themes and plugins tend to add JavaScript and styles you don't need. With Astro you start from a page with nothing extra and add only what's needed.
Sources
Facts checked on . Written and reviewed by Albert Gómez Vives. How we write these guides.