Page Speed Optimisation: Taking a PageSpeed Score from 40 to 95 in One Week
In this article
A PageSpeed Insights score in the 40s can usually be moved into the 90s in a week, provided you can change the code and the server. The score is not a mystery. It is a weighted sum of a handful of lab measurements. On most slow sites the same four things drag it down: oversized images, CSS and JavaScript that block the first paint, third-party scripts, and a slow server response. Fix those in that order and the number moves.
This is the seven-day order we use when a client comes to us with a red score. Each day has one job, because the fixes interact and doing them one at a time tells you which one worked.
One caution before day one. The score is a lab test run on a simulated mid-range phone. It is useful because it is repeatable, but Google ranks on field data from real visitors, which lags your changes by up to 28 days. Both numbers matter; the lab score is just the one you can move in a week.
What the score is made of
PageSpeed Insights runs Lighthouse against your page on a throttled connection with a slowed-down CPU, to approximate a cheap Android phone on a weak mobile signal. It then combines five timings into one number. In Lighthouse's published scoring, Total Blocking Time carries 30% of the weight, Largest Contentful Paint and Cumulative Layout Shift 25% each, and First Contentful Paint and Speed Index 10% each. Lighthouse colours the result red from 0 to 49, orange from 50 to 89 and green from 90 to 100.
Two things follow. Blocking time, which is almost entirely JavaScript, is the single biggest lever. And layout shift is worth as much as load time, so a page that loads quickly but jumps about as fonts and images arrive is capped well below 90. Our Core Web Vitals guide explains how the lab score relates to the field thresholds Google actually ranks on.
Day 1: measure and list the causes
Do not change anything yet. Run PageSpeed Insights on the home page and the two pages that matter most commercially, on mobile and on desktop, and save the reports. Then open the page in Chrome DevTools and record:
- Total transfer size and request count from the Network panel, with the third-party filter on and off.
- The largest files on the page, sorted by size. On a slow site the top of the list is images, followed by JavaScript bundles and web fonts.
- The element Lighthouse names as the Largest Contentful Paint element, and whether it is an image, a background image or text.
- Unused CSS and JavaScript from the Coverage tab, which shows what fraction of each file the page never touched.
- The server response time from the Timing tab on the first request, before any of the page has rendered.
Write each Lighthouse audit that fails into a list with the file or element it names. That list is the week's work order.
Day 2: images
Images are usually most of the page weight, and the fix is mechanical. For every image: serve it at the size it is displayed, in a modern format, and load it only when it is needed.
- Resize. A photo displayed at 600 pixels wide does not need to be 4,000 pixels wide. Generate two or three sizes and let the browser pick with srcset and sizes.
- Convert. WebP is supported by every current browser and is markedly smaller than JPEG at the same quality; AVIF is smaller again for photographs. Our comparison of WebP, AVIF and JPEG XL goes through the trade-offs, and the image format tester shows the saving on your own photo before you commit.
- Defer what is off screen. Add loading="lazy" to images below the first screen and nowhere else. We cover the detail, including the mistakes, in our post on lazy loading images without hurting performance.
- Prioritise the hero. The main image at the top gets fetchpriority="high" and is never lazy-loaded. If it is a CSS background image, make it an img element so the browser finds it in the HTML rather than after the stylesheet has loaded.
- Give every img element width and height attributes so the browser reserves the space before the file arrives.
On the business websites we build, the resizing and conversion happen at upload time with Pillow. Staff can upload whatever they have and the templates always get the right sizes.
Day 3: CSS, JavaScript and fonts
The browser reads the HTML from the top. When it meets a stylesheet it stops painting until the stylesheet has downloaded, because it cannot know what the page looks like without it. When it meets a script without defer or async it stops parsing altogether until the script has downloaded and run. Every one of these is a round trip the visitor spends looking at a blank screen.
- Put the CSS the first screen needs inline in the head and load the rest from a stylesheet further down. Failing that, cut the stylesheet down with the Coverage tab's help.
- Add defer to every script tag that is not needed to render the first screen, which is nearly all of them.
- Delete JavaScript that exists for a feature nobody uses. Carousels, parallax effects and animation libraries are the usual suspects.
- Self-host fonts, use two weights at most, subset them to the characters you need, set font-display to swap, and preload the one file the first screen uses.
<link rel="preload" href="/static/fonts/body-latin.woff2" as="font" type="font/woff2" crossorigin>
<script src="/static/js/app.js" defer></script>
Day 4: third-party scripts
Each marketing tag is a download from another company's server, followed by JavaScript running on the visitor's phone. Blocking time is the largest part of the score, and on most business sites most of the blocking time belongs to scripts the business did not write.
- List every third-party script and the person who wants it. Remove anything without an owner.
- Move the rest behind the page load. In Google Tag Manager, trigger tags on Window Loaded rather than Page View.
- Load embeds on demand. A YouTube video becomes a thumbnail that loads the player when clicked. A map becomes a static image with a link. A chat widget becomes a button that fetches the widget on first click.
- Make consent do real work. A script the visitor has not consented to should not be downloaded at all, which also removes it from the score.
Day 5: the server
Nothing on the page can start until the server sends the first byte of HTML. If that takes over a second, the rest of the week's work is queued behind it.
- Measure Time to First Byte and fix the backend first: slow queries, missing indexes, N+1 queries in templates. Our post on TTFB and server response time covers how to find them in Django.
- Cache pages that are the same for every visitor. Django's per-view cache serves a built page from memory instead of rebuilding it for each request.
- Compress text. Brotli or gzip on the web server shrinks HTML, CSS and JavaScript considerably before they leave the server.
- Set long cache lifetimes on static files with hashed filenames, so a returning visitor downloads nothing that has not changed. Django's ManifestStaticFilesStorage does the hashing; the web server sets the header. The layers are explained in our post on browser, server and CDN caching.
- Serve over HTTP/2 or HTTP/3 so many small files can share one connection.
location /static/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
Days 6 and 7: stability, interaction and the re-test
Day 6 is for the two parts of the score that are not about load time. Layout shift comes from anything that arrives late and pushes content: images without dimensions (fixed on day 2), fonts that swap in with different line heights, cookie banners injected at the top of the page, and ads or embeds without a reserved box. Give each a fixed size in CSS. Blocking time comes from long JavaScript tasks. After days 3 and 4 what remains is usually your own code, and the Performance panel in DevTools shows which function is holding the main thread.
Day 7, run the same PageSpeed Insights tests as day 1 and put the reports side by side. Each day's work should clear a predictable group of audits:
| Day | Audits that should clear | Score parts affected |
|---|---|---|
| 2 (images) | Image sizing, image format, off-screen images, missing width and height | LCP, CLS |
| 3 (CSS, JavaScript, fonts) | Render-blocking resources, unused CSS and JavaScript, text hidden during font load | FCP, LCP, TBT |
| 4 (third parties) | Third-party code impact, main-thread work, JavaScript execution time | TBT |
| 5 (server) | Initial server response time, text compression, cache policy for static assets | FCP, LCP |
| 6 (stability) | Large layout shifts, long main-thread tasks | CLS, TBT |
If an audit is still failing, the report names the file or element responsible, and that is the next job. A score that stalls in the 80s almost always has one remaining long task or one remaining render-blocking file.
Where to start
If you own the code, start with day 1 and do not skip it. The measurements tell you whether your week is an image problem or a JavaScript problem, and the order of days 2 to 5 is the order of likely payoff.
If you are on a page builder or a theme with a dozen plugins, days 2, 4 and 5 are still open to you. They will usually get the score out of the red, but the theme's own JavaScript sets a ceiling you cannot move without changing platform. That ceiling is the main reason we hand-code. With no theme, the first screen is HTML, one stylesheet and the images it needs, and the score starts in the 90s rather than being fought back to them.
After day 7, leave it 28 days and check the field data in Search Console. That is the number Google uses, and it is the one that tells you whether real visitors on real phones felt the difference. What that difference does to enquiries and sales is covered in our post on how high-performance websites convert.