Case file 04Performance8 min read

One blurred SVG cost 1.4 seconds: a landing page diet

A static marketing page that shipped as an app, and how one long day of measured fixes made it about seven times lighter.

Read by an AI voice of Sajib. Words light up as he reads.

I ran Lighthouse on our landing page and looked at the total size first. It was 13.4 MB, which is a lot for a marketing page whose content never changes.

Lighthouse is a tool in Chrome that loads a page, measures how fast it is, and gives it a score. On this page, the score was poor on desktop and worse on mobile.

The page belonged to a social media management product. In one long day it got about seven times lighter and much faster. Below are the strangest fix of the day, the biggest one, and the part that still isn’t good.

A static page that shipped as an app

The page was built with Next.js. Its content was the same for every visitor, so Next.js built the HTML ahead of time, which was fine.

The problem was that every section was marked "use client". In Next.js, that line makes a component a client component: its code is sent to the browser as JavaScript and runs there, and the browser then hydrates it. Hydration is when React takes the HTML the server sent and attaches event handlers to it. So the whole static page was sent twice: once as HTML, and again as JavaScript.

Fig. 4.1 · Marking every section as a client component sent the page once as HTML and again as JavaScript.

Why was every section a client component? Each section had a scroll animation built with GSAP, an animation library. The animation needed a ref to find its elements, and in Next.js a ref needs a client component. The markup itself never changed after the first render.

There was also a lot of media. An 11.5 MB product demo video sat below the first screen but still downloaded as soon as the page opened. A dozen smaller videos also made requests that most visitors would never need.

Before I changed anything, I wrote a plan with one firm rule: no visual or animation changes. Every animation had to look the same before and after, checked against production. That rule decided the order of the work.

The SVG that took 1.4 seconds to paint

Lighthouse reports Largest Contentful Paint (LCP). LCP is the time until the biggest visible element on the screen is drawn. It is one of the main numbers Google uses to judge page speed. On desktop, our LCP was 3.0 seconds.

I expected the biggest element to be the headline or a hero image. It turned out to be a decorative background layer behind the hero.

The background was a small SVG file, only 2.3 KB. It downloaded in about 84 milliseconds. Then the browser spent about 1.4 seconds drawing it before the first paint.

The SVG used four very large blur filters. Large blurs are expensive to draw, and the browser had to draw this one before it could show the page.

The art was just a soft gradient, so a normal bitmap image would lose nothing. I rendered the SVG once into a 33 KB WebP image. Because the art is so blurred, stretching the smaller image in CSS looks the same. I also told the browser to download this image early, with high priority.

Desktop LCP went from 3.0 seconds to 1.5 seconds. That was the best single fix of the day, and it came from a file I would never have suspected.

Stop downloading videos nobody asked for

The demo video was the biggest file on the page, and almost nobody saw it without scrolling, so it shouldn’t download until the visitor gets close to it.

The usual answer is preload="none", but the browser ignores that setting when the video also has autoPlay, because autoplay forces the download to start.

So I removed the source completely. The video now renders with only its poster image and no src. When it gets close to the screen, an IntersectionObserver gives it the source and starts playback. IntersectionObserver is a browser API that tells your code when an element enters or comes near the visible area. The smaller videos now load on first hover.

I also re-encoded the demo video at a lower quality setting. It went from 11.5 MB to about 4 MB, and I checked it frame by frame for visible loss.

After this change, the page in production went from 13.4 MB to 1.9 MB. No video downloads at all when the page first loads.

Fig. 4.2 · Most of the weight was video that most visitors never watched.

Server components with thin client wrappers

This was the main change. Next.js has server components. A server component runs only on the server, and only its HTML reaches the browser. It sends no JavaScript for its own markup.

One property of server components is easy to forget. If a server component renders some content and passes it into a client component as children, that content stays server-rendered. So a section doesn’t need to be a client component to have an animation. Only a thin wrapper does.

Look at Reveal below. It is the only part that is sent as JavaScript. The section inside it stays plain HTML.

"use client";
// Illustrative: the only part that hydrates.
export function Reveal({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);
  useRevealOnScroll(ref); // finds [data-reveal] elements in the HTML
  return <div ref={ref}>{children}</div>;
}

// A server component: its markup ships as HTML, not JavaScript.
export default function Testimonials() {
  return <Reveal><section>{/* static content */}</section></Reveal>;
}

In this step I didn’t change the GSAP code at all. The animations looked for the same elements as before. So if an animation broke, I knew the cause was the move to server components, not the animation code.

Eleven sections became server components. The parts that really needed interaction, like the FAQ accordion and the video lightbox, became small client components of their own.

The mobile number that mattered here was Total Blocking Time (TBT). TBT measures how long the main thread is too busy to respond to the user, for example during hydration. On mobile, it went from 2,930 milliseconds to 110 milliseconds. The page height stayed exactly the same, so nothing moved.

A series of smaller cuts

With the JavaScript problem solved, CSS became the next problem. The landing page loaded one big stylesheet that contained styles for the entire app. I split it, so public pages load only the styles they use. That roughly halved the CSS on the landing page. To check that I hadn’t broken some forgotten page, I had three AI coding agents compare screenshots of 17 public pages in parallel.

The rest of the day was smaller changes, each one measured:

  • Stop preloading fonts and images that the first screen doesn’t use.
  • Load the analytics library when the browser is idle. Because that could miss errors in the first second or two, the next change saves those early errors and sends them once analytics loads.
  • Fetch pricing on the server and cache it for an hour. The page now makes no API requests from the browser.

One idea didn’t work. An experimental Next.js option to inline the CSS would have removed the stylesheet requests completely. On this codebase it crashed the build. I wrote that down in the config and moved on.

Replacing GSAP with Motion

The rest of the app already used Motion, another animation library. GSAP existed only on the marketing pages, so the page was paying for two animation libraries.

The danger was undoing the server component work. So the HTML stayed the same, and the thin wrappers used Motion’s functions instead of GSAP’s. I moved one animation per commit and compared screenshots at the same scroll positions before and after.

One detail surprised me. GSAP and CSS use similar names for easing curves, but they don’t mean the same thing. GSAP’s power2.out is the same as a cubic curve. If you copy the names directly, every animation feels slightly different.

After GSAP was gone, a local Lighthouse run showed desktop LCP at about 1.1 seconds. That was the first time desktop LCP was in the green.

What is still not good

Mobile LCP is still poor. Lighthouse simulates a slow 4G network and a slower phone. Under those conditions, mobile LCP went from 9.2 seconds to 5.65 seconds. Lighthouse calls anything under 2.5 seconds good, so 5.65 seconds is still in the “poor” range.

On a fast connection, the LCP was about 100 milliseconds. So the remaining cost is the total amount of data that must arrive before the hero appears: fonts, CSS, framework JavaScript and the hero images. I listed those as the next steps, and I haven’t done them yet.

My measurements also came from different places. Some numbers came from production and some from local builds. That makes the results harder to compare honestly. Next time I would run one fixed Lighthouse setup in CI on every commit.

One later lesson came from the pricing change. I had shipped it with a hard-coded fallback price list, for when the API failed. Two months later, I found that fallback among about 15 places with hard-coded prices. I removed it, so every price now comes from the API. A silent fallback makes it hard to know whether visitors see live data or old data.

What I learned

Look at the LCP element first. I almost started with the JavaScript, because the hydration cost was obvious. The best win was a decorative background.

A small file can still be expensive to draw. If an SVG is just a soft blur, use a bitmap image.

To lazy-load a video that autoplays, don’t give it a src until you need it. preload="none" is not enough.

Change one kind of thing at a time. I moved the server and client boundary first and replaced the animation library later. So every problem pointed to one kind of change.

Product names and some details are changed or left out. The engineering is real.