Tag: core web vitals

  • Edge Functions for Frontend Designers: What Cloudflare Workers and Vercel Edge Actually Mean for UK Web Performance

    Edge Functions for Frontend Designers: What Cloudflare Workers and Vercel Edge Actually Mean for UK Web Performance

    Edge computing sounds like something a backend engineer should explain to you whilst you nod politely and think about font weights. I get it. The infrastructure layer has historically been not-your-problem, and for a long time that was fine. But edge functions have crossed a line. They are now genuinely useful to frontend designers and developers in ways that directly affect the things you spend your days obsessing over: page speed, personalisation, A/B testing, and whether your LCP score makes you want to cry.

    This is my attempt to explain edge functions as a frontend concern, not an ops concern, with real-world patterns UK teams are actually shipping in 2026.

    Frontend developer writing edge functions for performance improvements on a dark-themed code editor
    Photo by Daniil Komov on Pexels

    What edge functions actually are (without the waffle)

    A traditional web request goes: user’s browser, CDN cache, your origin server somewhere in a data centre. The origin might be in London if you’re lucky, Dublin if you’re using AWS eu-west-1, or somewhere entirely unhelpful if you never thought about it. Every uncached request hits that server, adds latency, and makes your Time to First Byte worse.

    Edge functions run code at CDN nodes, physically close to the user. Cloudflare has over 300 data centre locations globally. Vercel’s edge network is similar in concept. When a request comes in, instead of bouncing all the way to your origin, a small piece of JavaScript (or TypeScript) runs at the nearest node and returns a response. We’re talking single-digit millisecond execution in many cases.

    The key constraint worth knowing: edge functions are not Node.js. They run in a V8 isolate environment, which means no file system access, limited APIs, and very short execution windows. That constraint is actually what makes them useful for the frontend layer, because it forces you to keep edge logic small and sharp.

    Why this matters for edge functions frontend performance UK specifically

    UK users suffer more latency than they should from services hosted without European region configuration. If your Next.js app’s API routes are running serverless functions in us-east-1 because nobody changed the default, every dynamic request is crossing the Atlantic. Vercel’s edge runtime and Cloudflare Workers both put execution closer to the UK, and the difference in TTFB can be 200-400ms on uncached requests. That is not trivial when UK Core Web Vitals data shows that LCP and INP failures correlate directly with conversion drops on British e-commerce and SaaS sites.

    The Cloudflare network has a major presence in London (Docklands), Manchester, and Edinburgh. Vercel routes UK traffic through Frankfurt and Amsterdam primarily, with London capacity added in 2024. Either way, you are getting dramatically closer to your users than a single-region origin server.

    Three concrete things you can do with edge functions without a backend engineer

    1. Personalisation without client-side flicker

    The standard approach to personalisation in a React or Next.js app is: render the generic page, load JavaScript, check a cookie or API call, then swap in the personalised content. Users see a flash of the wrong content. It is grim, and it tanks your LCP because the meaningful content arrives late.

    Edge functions fix this by reading cookies and headers before the HTML is assembled. A Vercel Edge Middleware file (literally middleware.ts in your project root) can inspect the incoming request, check a user segment cookie, and rewrite the URL to a different version of the page before the browser sees anything. The user gets personalised HTML on the first response. No flicker, no extra round trip, no bespoke backend logic required.

    A practical example: a UK SaaS product serving both SME and enterprise tiers can serve entirely different homepage layouts based on a cookie set at signup, handled entirely in around 20 lines of TypeScript at the edge. No server, no database call, no delay.

    2. A/B testing that doesn’t torch your Core Web Vitals

    Client-side A/B testing with tools like Google Optimize (now retired) or its replacements typically inject test logic after the page loads. The result is layout shift, delayed LCP, and Cumulative Layout Shift scores that your performance audit will flag immediately. Edge-based A/B testing sidesteps this entirely.

    The pattern is straightforward. Your edge function generates or reads a test bucket (usually a random assignment stored in a cookie), then serves bucket A or bucket B of your HTML before the response leaves the CDN. From the browser’s perspective, there is only ever one version of the page. The Cloudflare Workers documentation has solid examples of this pattern using the HTMLRewriter API, which lets you modify HTML at the edge without reconstructing the entire response.

    I’ve used this pattern on a Next.js project for a UK fintech startup. We ran a button colour test (yes, really, the client insisted) across 50,000 monthly visitors without touching the origin deployment or writing a single line of backend code. The Lighthouse scores stayed identical between variants because the HTML was identical in structure, just different in content.

    3. Geolocation-based content without a postcode lookup API

    Cloudflare Workers and Vercel Edge both expose request geolocation headers automatically. cf-ipcountry in Cloudflare, and x-vercel-ip-country and x-vercel-ip-city in Vercel. You can use these to show UK-specific pricing (£ GBP, VAT-inclusive), route Scottish users to Scottish Gaelic content variants, or surface region-relevant promotions, all without a database call or a paid IP geolocation API.

    This is particularly useful for UK e-commerce sites that need to show duty-included pricing to GB users whilst showing export pricing to EU visitors post-Brexit. Handling that at the edge means the correct price is in the HTML from the first byte. No price flicker, no client-side currency swap, no additional JavaScript bundle weight.

    The Vercel vs Cloudflare choice for UK frontend teams

    If you are already deploying on Vercel, the edge runtime is the path of least resistance. Your middleware.ts file is just part of the project, it deploys automatically, and the routing primitives are well-documented. The limitation is that Vercel’s edge functions are tightly coupled to their platform, so you are buying into that ecosystem.

    Cloudflare Workers are more portable and more powerful. You can run them in front of any origin, including a Vercel deployment, which is a combination I have seen UK agencies use to get the best of both. Workers also have access to Cloudflare’s KV store (a globally replicated key-value database) and Durable Objects for stateful logic, which opens up patterns that Vercel middleware simply cannot do.

    For a solo developer or small UK agency, Vercel’s free tier is generous enough for most projects. Cloudflare Workers’ free tier gives you 100,000 requests per day, which is reasonable for prototyping. The paid tiers for both are reasonable once you are shipping something with real traffic.

    What edge functions cannot do (and why you still need some backend)

    Edge functions are stateless and fast, which means they are the wrong tool for heavy computation, database writes, large payload processing, or anything requiring persistent connections. You still need an actual backend (or a serverless function in a proper runtime) for those things. The edge layer is the routing and transformation layer, not the application logic layer.

    I’d also point out that cold start times, whilst dramatically better than traditional serverless functions, are not zero. Vercel’s edge functions typically have sub-1ms cold starts. Cloudflare Workers are similar. But if your logic becomes complex enough, you will want to profile it. The edge environment rewards small, focused functions.

    One thing this connects to for design teams: if you are building a Micro-SaaS product as a solo developer and you have been putting off personalisation because it felt like infrastructure work, edge middleware genuinely removes that blocker. You do not need a dedicated backend engineer to implement sensible routing logic in 2026.

    Getting started without breaking anything

    My recommendation: start with a read-only middleware. Something that inspects a cookie or a header and adds it to a request header for downstream consumption. This is zero-risk, teaches you the API surface, and gives you something to show in a pull request. Once that is merged and boring, move to URL rewrites. Then cookie setting. Then A/B bucket assignment. Each step is independently reversible.

    The Vercel middleware documentation is genuinely good. The Cloudflare Workers quick-start is also excellent, and the playground at workers.cloudflare.com lets you write and test Workers in the browser with live request inspection. Both platforms have strong TypeScript support, which matters if you are working on a codebase where designer-developer handoff is already type-driven.

    Edge functions are not magic, but they are one of the more genuinely useful infrastructure concepts to land in the frontend toolkit in the last few years. The performance gains are real, the personalisation patterns are practical, and the barrier to entry is low enough that a frontend developer comfortable with TypeScript can be productive within an afternoon. That is a rare combination in infrastructure land.

  • Why Your Website’s Core Web Vitals Are Still Broken in 2026 (And How to Actually Fix Them)

    Why Your Website’s Core Web Vitals Are Still Broken in 2026 (And How to Actually Fix Them)

    Right. You’ve run PageSpeed Insights, stared at a wall of amber and red scores, and muttered something unprintable at your screen. Welcome to the club. Despite Google making Core Web Vitals a ranking signal years ago, a staggering proportion of UK small business and e-commerce sites are still failing at least one metric. According to the ONS data on UK internet industry, the number of UK businesses trading online continues to grow, which makes it all the more baffling that so many of them are haemorrhaging rankings because of fixable performance issues. This is your technically grounded guide to the core web vitals fix your UK website actually needs in 2026.

    Developer analysing core web vitals fix for a UK website in 2026 on multiple monitors
    Developer analysing core web vitals fix for a UK website in 2026 on multiple monitors

    What Are Core Web Vitals and Why Do They Still Matter in 2026?

    Three metrics. That’s all Google is officially measuring under Core Web Vitals: Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS). INP replaced First Input Delay in early 2024 and it’s been quietly brutalising sites ever since. These aren’t abstract benchmarks invented by committee; they map directly to how a real human being experiences loading a page on a 4G connection on the Tube.

    LCP measures how fast your biggest visible element renders. INP measures how snappy your site feels when someone taps, clicks, or types. CLS measures whether your page jumps around like a nervous ferret while it loads. Fail any of them and you’re not just annoying your users; you’re handing a quiet ranking penalty to competitors who bothered to sort theirs out.

    Why UK SME and E-Commerce Sites Fail More Than They Should

    I’ve looked at a lot of UK business sites over the years and the failure patterns are almost always the same. It’s rarely one catastrophic problem. It’s death by a thousand cuts: a bloated WooCommerce theme, render-blocking Google Tag Manager scripts, hero images served without modern compression, third-party chat widgets loading synchronously. Each one adds a few hundred milliseconds. Collectively they torpedo your LCP.

    UK e-commerce sites in particular tend to inherit technical debt from theme marketplaces. Themes built on Bootstrap 4, autoloading twelve Google Fonts variants, carousels powered by jQuery plugins from 2019. The stacking effect is brutal. A site that looks fine on a developer’s M3 MacBook Pro over fibre will absolutely fall apart for someone browsing on an iPhone SE in a post office queue in Wolverhampton.

    Fixing LCP: The Largest Contentful Paint Problem

    Your LCP target is under 2.5 seconds. Most failing UK sites are sitting between 3.5 and 6 seconds. The biggest culprits are almost always images and render-blocking resources.

    Start with your hero image. If it’s a JPEG or PNG being loaded via a CSS background, that’s two problems at once. Switch to WebP or AVIF (AVIF compression is genuinely remarkable at this point), serve it as an <img> element with proper dimensions declared, and add fetchpriority="high" to the tag. That single attribute tells the browser this image is critical and to fetch it immediately rather than queuing it behind other resources.

    <img
      src="hero.avif"
      width="1200"
      height="630"
      fetchpriority="high"
      alt="Your descriptive alt text"
    >

    Next: preload your LCP image in the <head>. This is still criminally underused on UK sites.

    <link rel="preload" as="image" href="hero.avif" fetchpriority="high">

    Finally, audit your render-blocking scripts. Google Tag Manager firing synchronously in the <head> is an LCP killer. Move third-party scripts to load with defer or async wherever possible. GTM itself should load asynchronously; if it isn’t, something has gone wrong with your implementation.

    Chrome DevTools performance panel showing long tasks relevant to core web vitals fix
    Chrome DevTools performance panel showing long tasks relevant to core web vitals fix

    Fixing INP: Interaction to Next Paint Is the Hard One

    INP is the metric that’s caught the most sites off-guard since it replaced FID. The threshold for a good score is under 200 milliseconds. Poor is anything over 500ms. The nuance here is that INP measures the worst interaction across an entire page session, not just the first one. That means a sluggish dropdown menu or a heavy on-click handler buried in a product filter can tank your entire score.

    The main culprit for high INP on UK e-commerce sites is long tasks on the main thread. JavaScript that runs for more than 50ms without yielding blocks the browser from responding to user input. Here’s the pattern to break it up:

    // Instead of one long synchronous function:
    function heavyTask() {
      // ...200ms of work...
    }
    
    // Yield to the browser between chunks:
    async function yieldingTask() {
      for (const chunk of dataChunks) {
        processChunk(chunk);
        await new Promise(resolve => setTimeout(resolve, 0));
      }
    }

    The scheduler.postTask() API is worth exploring if you’re on a modern stack; it gives you fine-grained control over task priority. For WordPress and WooCommerce sites, the quickest win is usually auditing which plugins are registering event listeners on every page. WooCommerce cart fragments, live chat scripts, cookie consent managers; each one adds JavaScript weight that the browser has to process before it can respond to the next click.

    Use Chrome DevTools’ Performance panel (or the slightly more accessible Web Vitals extension) to identify which interactions are generating the longest tasks. Look for the red triangles. Then work backwards to the script responsible.

    Fixing CLS: Stop Your Page Jumping Around

    Cumulative Layout Shift should be under 0.1. It’s the most visually obvious failure and often the easiest to fix, yet plenty of UK sites are still shipping CLS scores of 0.3 or worse.

    The classic cause: images without declared dimensions. When the browser doesn’t know how tall an image is before it loads, it reserves no space. Then the image appears and shunts everything down the page. The fix is a single line of CSS that’s been good practice for years but somehow still gets skipped:

    img, video {
      aspect-ratio: attr(width) / attr(height);
      height: auto;
      width: 100%;
    }

    Always declare explicit width and height attributes on your <img> tags too. The browser uses these to calculate space before the image loads.

    Web fonts are the other sneaky CLS source. When your custom font loads and swaps in, text reflows and shifts the layout. The fix is font-display: optional for non-critical fonts, or font-display: swap combined with a closely matched system font fallback using the size-adjust CSS descriptor. The font matching tools from Malte Ubl’s Fontaine project are genuinely useful here for generating fallback metrics automatically.

    Ad slots, banners, and dynamically injected content are the third category. Reserve space for them explicitly with CSS. A banner that loads after the DOM has painted and pushes your content down by 60 pixels will absolutely destroy your CLS score.

    Measuring the Right Way: Real User Data vs Lab Data

    PageSpeed Insights shows you two sets of data: lab data (simulated, consistent, useful for debugging) and field data from the Chrome User Experience Report (CrUX). Google’s ranking decisions are based on CrUX field data, not lab scores. A site can score 95 in PageSpeed lab conditions and still fail Core Web Vitals in the field if real users on real networks and devices are having a different experience.

    If your site doesn’t yet have enough traffic to appear in CrUX, you’re assessed at the origin level or not at all. But you should still optimise; you’re building the performance foundation for when the data does accumulate. Use the Google Search Console Core Web Vitals report to see page-group level field data for your actual UK users.

    The bottom line for a core web vitals fix on a UK website in 2026 is this: it’s almost never one thing. It’s the compound effect of images, scripts, fonts, and layout choices that were each fine in isolation but terrible together. Audit methodically, fix the highest-impact items first (LCP image delivery and render-blocking scripts will move the needle fastest), and measure with field data, not just lab scores. Your rankings, and your users, will thank you for it.

    Frequently Asked Questions

    What is a good Core Web Vitals score in 2026?

    Google defines ‘good’ as LCP under 2.5 seconds, INP under 200 milliseconds, and CLS under 0.1. All three thresholds need to be met at the 75th percentile of real user page loads to pass. Hitting two out of three still counts as a partial failure.

    How do I check my Core Web Vitals for free?

    Google Search Console gives you real-user field data grouped by page type, which is the most valuable report for UK site owners. PageSpeed Insights (pagespeed.web.dev) gives you both lab and field data for individual URLs. The Chrome Web Vitals browser extension lets you measure in real time as you browse.

    Does fixing Core Web Vitals actually improve Google rankings?

    Yes, though it’s one signal among many. Google uses Core Web Vitals as a tiebreaker when content quality is broadly similar between competing pages. For competitive UK e-commerce and local search queries, the difference between a passing and failing score can visibly shift rankings. More importantly, faster sites convert better.

    Why is my WordPress site failing INP?

    WordPress and WooCommerce sites typically accumulate JavaScript from multiple plugins all registering event listeners and running tasks on the main thread simultaneously. Cart fragment scripts, live chat widgets, cookie consent managers, and page builder scripts are common culprits. Audit your loaded scripts with Chrome DevTools and remove or defer anything not critical to the initial interaction.

    How long does it take to fix Core Web Vitals?

    Technical fixes can be implemented in a day or two for a developer who knows what they’re looking for. However, Google’s CrUX field data updates on a rolling 28-day window, so you won’t see improvements reflected in Search Console immediately. Expect three to four weeks before field data catches up to your fixes.

  • Why Developers Are Finally Taking Browser Performance Seriously

    Why Developers Are Finally Taking Browser Performance Seriously

    Somewhere between your beautifully crafted Figma mockup and the first rage-click from a user, something terrible happens: the browser. That is why browser performance optimisation has quietly become one of the hottest topics in modern front end development.

    What is browser performance optimisation, really?

    In simple terms, it is everything you do to make the browser do less work, more cleverly. Less layout thrashing, fewer pointless reflows, smarter JavaScript, and assets that do not weigh more than the average indie game. The goal is not just fast load times, but fast feeling interfaces – snappy, responsive, and predictable.

    For modern web apps, this goes way past compressing images and minifying scripts. We are talking render pipelines, main thread scheduling, GPU acceleration, and how your component architecture quietly sabotages all of that.

    Why browser performance optimisation suddenly matters

    Users have become extremely unforgiving. If your interface stutters, they assume your entire product is flaky. On top of that, Core Web Vitals now quantify just how painful your site feels: Largest Contentful Paint, Cumulative Layout Shift, Interaction to Next Paint – all those scary graphs that tell you your homepage is basically a PowerPoint slideshow.

    Designers are also pushing more motion, more microinteractions, more everything. That is great for user delight, until your animation stack is running on the main thread and your 60 fps ambition turns into a flipbook. Performance is now a design constraint, not just an engineering afterthought.

    Key principles of modern browser performance optimisation

    There are a few core ideas that keep showing up in every high performing app:

    • Do less on the main thread: Long JavaScript tasks block input and make your UI feel sticky. Break work into smaller chunks, use requestIdleCallback sensibly, and offload heavy logic to Web Workers when you can.
    • Reduce layout and paint work: Excessive DOM depth, layout thrashing, and wild CSS selectors all add up. Use transform and opacity for animations, avoid forcing synchronous layout reads, and be suspicious of anything that triggers reflow in a loop.
    • Ship less code in the first place: Code splitting, route based chunks, and ruthless dependency pruning are your friends. That UI library you installed for one button? Probably not helping.
    • Prioritise what is actually visible: Lazy load offscreen images, defer non critical scripts, and prefetch routes you know users will hit next. The first screen should feel instant, even if the rest of the app is still quietly loading.

    Design decisions that secretly destroy performance

    Performance problems are often baked in at the design stage. Infinite scroll with complex cards, glassmorphism everywhere, heavy blur filters, and full bleed video backgrounds all look lovely in static mocks. In a real browser, they turn into a GPU stress test.

    Good product teams now treat motion, depth, and visual effects as budgeted resources. Want shadows, blurs, and parallax? Fine, but you only get so many before the frame rate drops. Designing with a performance budget forces smarter choices, like using subtle transform based motion instead of expensive filter effects.

    Tools that actually help (and ones that just make graphs)

    If you are serious about browser performance optimisation, you will live inside the browser devtools performance tab more than you would like to admit. Flame charts, layout thrash detection, and CPU profiling are where the real answers live.

    Lighthouse and Core Web Vitals reports are great for quick health checks, but they are the blood tests, not the surgery. For deep issues, you will be looking at long tasks, JS heap snapshots, and paint timelines to spot where your shiny framework is quietly doing way too much work.

    Performance as a continuous habit, not a one off sprint

    The most successful teams treat performance as an ongoing discipline. They set budgets for bundle size, track key metrics in their monitoring tools, and fail builds when things creep over thresholds. They also keep an eye on infrastructure choices like web hosting, CDNs, and edge caching, because the fastest code in the world cannot outrun a painfully slow server.

    Design and dev team discussing UI and browser performance optimisation in a modern office
    Laptop showing devtools timeline used for browser performance optimisation beside UI sketches

    Browser performance optimisation FAQs

    What is the main goal of browser performance optimisation?

    The main goal of browser performance optimisation is to make web pages and apps feel fast and responsive from the user’s perspective. That means reducing main thread blocking, minimising layout and paint work, and prioritising visible content so interactions feel instant, even on average devices and networks.

    How can designers help improve browser performance?

    Designers can help by working with performance budgets, limiting heavy effects like blurs and shadows, and planning motion that can be implemented with transform and opacity instead of expensive layout changes. Collaborating early with developers ensures that visual ideas are achievable without tanking frame rates.

    Which tools are best for browser performance optimisation?

    For serious browser performance optimisation, the browser’s own devtools are essential, especially the performance, network, and memory panels. Lighthouse and Core Web Vitals reports provide a good overview, while flame charts, CPU profiling, and layout/paint timelines reveal the deeper issues affecting real user experience.