Color scheme

Filter versus Backdrop Performance

The core readings introduced filter and backdrop-filter and mentioned that they have a GPU cost. This choose topic digs into what that cost actually looks like: how the browser composites filtered elements, why backdrop-filter is more expensive than filter, how blur radius and element size multiply the work, and how to measure all of it in DevTools. The goal is to build a practical intuition for when a filter is free enough to use without thinking, when it needs care, and when you should reach for a cheaper alternative.

How Filters Affect the Rendering Pipeline

The browser renders a page in stages: style calculation, layout, paint, and composite. Filters operate at the paint and composite stages. When you apply filter to an element, the browser paints the element to an offscreen buffer, runs the filter functions against those pixels, and then composites the result into the page. This is GPU work, and for most elements at moderate blur values it is fast enough that you will never notice.

backdrop-filter is more expensive because it adds an extra step. The browser must first composite everything behind the element into a temporary buffer, apply the filter to that buffer, and then paint the element itself on top. That "everything behind the element" part is the key cost: the browser is filtering pixels it has already composited, which means it is doing the compositing work twice for that region of the screen.

Both properties force the browser to promote the element to its own compositing layer. This is the same behavior you get from transform, opacity, or will-change. The layer promotion itself is cheap, but each layer consumes GPU memory, and too many layers can cause the GPU to thrash between buffers instead of rendering smoothly.

What Drives the Cost

Not all filter usage is equally expensive. Three factors determine how much work the GPU does:

  • Blur radius: blur() is the most expensive filter function because it samples neighboring pixels. A 4px blur samples a small neighborhood. A 40px blur samples a much larger area for every pixel in the element. The cost scales roughly with the square of the radius.
  • Element size: A blurred thumbnail is trivial. A blurred full-viewport hero image is thousands of times more pixels. The cost scales linearly with the element's pixel area.
  • Animation: A static filter runs once when the element paints. An animated filter (transitioning blur, brightness, or hue-rotate) runs the filter computation on every frame. At 60fps that is 60 filter passes per second.

The combination of all three is where real problems appear. A backdrop-filter: blur(20px) on a sticky full-width header that recomposites on every scroll frame is about the worst case you can create. Each scroll event triggers a re-filter of the entire viewport-width region behind the header, at a large blur radius, 60 times per second.

Measuring in DevTools

Chrome DevTools gives you two tools for seeing filter cost directly:

Paint Flashing

Open DevTools, press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the command palette, and type "Show paint flashing." Green rectangles flash over every region that the browser repaints. Scroll the page and watch which areas flash. If a filtered element flashes on every scroll frame, you are paying the filter cost continuously. If it only flashes once when it first appears, the cost is a one-time paint.

Performance Panel

Open the Performance panel and record a few seconds of interaction (scrolling, hovering, animating). Stop the recording and look at the frame chart. Each frame should complete in under 16ms for 60fps. Expand the "Paint" and "Composite Layers" sections to see how much time each frame spends on compositing. Long paint times or composite times that spike during scroll are strong signals that a filter is too expensive for that context.

Look for frames that exceed the 16ms budget. Click on them to see the detailed breakdown. If "Paint" dominates, the filter is causing expensive repaints. If "Composite Layers" dominates, you may have too many promoted layers competing for GPU memory.

Practical Decision Framework

Knowing the cost model lets you make informed choices instead of guessing:

  • Static filter on a small element (a card image, an avatar, a thumbnail): Almost always fine. The element paints once and the GPU handles it without breaking a sweat. Use freely.
  • Static backdrop-filter on a small element (a frosted glass tooltip, a small overlay): Usually fine. The double composite cost is real but small when the element is small.
  • Static backdrop-filter on a large element (a full-width sticky header, a modal overlay): Test on real devices. It may be fine on a modern laptop but janky on a budget phone. Have a fallback ready (solid semi-transparent background).
  • Animated filter or backdrop-filter: Be cautious. Keep the blur radius low, the element small, and always provide a prefers-reduced-motion fallback. Profile in DevTools before shipping.

Cheaper Alternatives

When a backdrop-filter is too expensive, consider these alternatives that produce visually similar results at lower cost:

  • A solid semi-transparent background with no blur. You lose the frosted effect but keep the visual separation between layers.
  • A pre-blurred background image. Generate a blurred version of the image at build time and swap it in behind the overlay. The browser displays a static image instead of computing blur per frame.
  • filter: blur() on a duplicated background element positioned behind the overlay. This moves the cost from backdrop-filter (which re-composites dynamically) to a static filter on a fixed element, which paints once.

Teaching Video Checklist

When you record your teaching video, make sure your teammates come away understanding these concepts:

  • Why backdrop-filter is more expensive than filter: the double-composite step
  • The three factors that drive filter cost: blur radius, element size, and animation frequency
  • A live demonstration of paint flashing in DevTools on a page with filtered elements, showing which elements repaint on scroll
  • A Performance panel recording comparing a page with and without a backdrop-filter: blur() on a sticky header, pointing out the frame time difference
  • At least one cheaper alternative to backdrop-filter and when it makes sense to use it
  • The prefers-reduced-motion fallback pattern for animated filters

Build a simple test page with a frosted glass sticky header over a scrollable image grid. Record the Performance panel while scrolling, then swap the backdrop-filter for a solid background and record again. Walk your teammates through the difference in frame timing so they can see the cost concretely.

Resources