Xerobit
Frontend & Design

CSS Box Shadow Performance: Measured Repaint Costs

Measured in Chrome 156: animating box-shadow on 100 cards drops to about 30 fps, the ::after opacity trick paints zero times, and filter drop-shadow is far slower.

MA Mian Ali Khalid Updated Nov 2, 2026 6 min read
Free tool
Box Shadow Generator
Visual CSS box-shadow builder. Control offset, blur, spread, color, inset. Multi-layer shadows. Live preview + copyable CSS.
Open tool →
On this page ⌄
  1. How it was measured
  2. Test 1: how much does blur radius cost?
  3. Test 2: animating the shadow itself
  4. The ::after technique, as copy-paste
  5. box-shadow vs filter: drop-shadow
  6. What is safe to animate
  7. FAQ
  8. Tested

A static box-shadow is cheap. The cost shows up when the shadow has to be repainted: when you animate it, or when something else in the same layer changes every frame. Both were measured in Chrome instead of repeating the usual advice. The results are less dramatic than most posts claim for a single card, and much worse than they admit for a grid of 100.

Build the shadows with the Box Shadow Generator; this page is about what they cost.

How it was measured

  • Chrome 156.0.8078.48 on Windows 11, Intel UHD Graphics (ANGLE/Direct3D11), driven with playwright-core, headless.
  • Page: a grid of 100 white cards (60px tall, border-radius: 10px) in a 1240px-wide container.
  • Frame cadence: requestAnimationFrame deltas over 3 seconds after a 500 ms warm-up. The baseline ran at about 127 callbacks per second, so read the numbers as relative to the test machine, not as absolute fps.
  • Reported: median of 3 runs for frames per second and the 95th percentile frame interval (p95), plus the number of Paint trace events from Chrome tracing.
  • Limit: one machine, one GPU. Whether rasterization ran on the GPU or in software was not confirmed. Use the ratios, and re-measure on your own target devices.

Test 1: how much does blur radius cost?

To isolate shadow painting, a script changed the background colour of all 100 cards on every frame, forcing every shadow to be repainted each time. This is a stress test, not a normal page.

shadow on each cardframes/s (median)p95 frame interval
none12716.8 ms
0 1px 4px126.716.8 ms
0 2px 10px13016.8 ms
0 5px 20px75.333.4 ms
0 10px 40px68.733.4 ms
0 20px 80px8233.4 ms

Up to a 10px blur no cost was visible. From 20px the frame interval doubled with 100 repainting cards. The 80px blur was not slower than 40px, so there is no clean "bigger blur, proportionally slower" curve in these results; the step between 10px and 20px is what repeated across runs. If your cards do not repaint every frame, none of this applies, which is the usual case.

Test 2: animating the shadow itself

Three versions of a hover-style effect, run as infinite alternating CSS animations on the same 100 cards:

/* A: animate box-shadow directly */
.card { box-shadow: 0 2px 4px rgba(0,0,0,.25); animation: s 1s ease-in-out infinite alternate; }
@keyframes s { to { box-shadow: 0 20px 40px rgba(0,0,0,.25); } }

/* B: pre-render the big shadow, animate opacity */
.card { position: relative; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  opacity: 0;
  animation: o 1s ease-in-out infinite alternate;
}
@keyframes o { to { opacity: 1; } }

/* C: lift with transform only */
.card { box-shadow: 0 2px 4px rgba(0,0,0,.25); animation: t 1s ease-in-out infinite alternate; }
@keyframes t { to { transform: translateY(-4px); } }
techniquep95 frame intervalworst framepaint events in 3 s
A: animate box-shadow116.8 ms150 ms4848 to 6262
B: ::after opacity16.8 ms66.7 ms0
C: transform only16.8 ms133 ms0

A ran at roughly 30 frames per second with a p95 over 100 ms, which is visible stutter. B and C produced no paint work at all after warm-up; the browser only composited. The occasional 50 to 130 ms worst frame in B and C did not repeat from run to run, so it is treated as noise from tracing, not a property of the technique. Callback rates for compositor-only animations are not comparable to A, so p95 and paint counts are compared instead of fps.

With fewer cards, there is nothing to fix

A and B were repeated with 1 and 10 cards. Both held a 16.8 ms p95 with no long frames. Animating box-shadow on a single hovered card is fine on this hardware. The problem is the combination: large blur, many elements, or a weak device. Optimise when you see it in a profile, not on principle.

The ::after technique, as copy-paste

This is B with a hover trigger, a transition and reduced-motion handling:

.card {
  position: relative;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.card:hover { transform: translateY(-4px); }
.card:hover::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .card, .card::after { transition: none; }
}

Both shadows exist at all times; only the second one fades in. The outer shadow is not drawn inside the pseudo-element's own box, so it does not cover the card content, and pointer-events: none keeps clicks going to the card. The cost is one extra shadow painted once per card.

box-shadow vs filter: drop-shadow

drop-shadow() follows the alpha shape of the element; box-shadow never does. An SVG circle confirms it: box-shadow painted a red rectangle around the 60x60 box, while drop-shadow painted a shifted circle and left the area outside the circle untouched.

The cost is the interesting part. Same stress test as Test 1 (100 cards repainting every frame):

effectframes/sp95 frame interval
box-shadow: 0 10px 40px68.733.4 ms
filter: drop-shadow(0 1px 4px)23.383.3 ms
filter: drop-shadow(0 10px 40px)6.3233.5 ms

For plain rectangles with rounded corners, box-shadow is the one to use. Reserve drop-shadow for transparent PNGs, SVG icons and cut-out shapes, and avoid it on a hundred repainting elements.

What is safe to animate

propertywhat was measured or what to expect
transform0 paint events (test C), even without will-change
opacity0 paint events (test B, on a pseudo-element)
box-shadowrepaints every frame; fine for 1 to 10 elements, about 30 fps at 100 with a 4px to 40px blur change
filter: drop-shadow()slowest option measured
width, height, top, lefttrigger layout; not measured

The first two rows are the whole trick: change only what the compositor can do alone, and pre-render the shadow you want to reveal. will-change: transform was not needed for a running CSS animation of transform (it was absent in test C). Keep it for elements you are about to animate from script, and remove it afterwards because every promoted layer holds memory.

FAQ

Does box-shadow hurt performance?

A static shadow does not. In testing, a 4px and a 10px blur on 100 repainting cards matched having no shadow at all. Animating it, or using a large blur on many elements that repaint, is where cost appears.

How do I animate box-shadow without lag?

Do not animate it. Put the target shadow on an ::after pseudo-element and animate its opacity, as in the code above. That measured zero paint events against thousands for the direct animation.

Is filter: drop-shadow slower than box-shadow?

In this test, yes: 6.3 frames/s versus 68.7 at a 40px blur on 100 repainting elements. It follows the shape of transparent images, which box-shadow cannot, so use it only where that matters.

Does a bigger blur radius make box-shadow slower?

Past roughly 10px, yes: in this setup the frame interval doubled at 20px. It did not keep growing at 80px, so do not assume a linear relationship.

Tested

Run on 2026-11-02: Chrome 156.0.8078.48, playwright-core, Windows 11, Intel UHD Graphics, headless. Tracing categories devtools.timeline, cc, gpu; frame intervals from requestAnimationFrame; 3 runs per scenario (2 for the 1 and 10 card checks). Not tested: Firefox, Safari, or any mobile device. Next: inset and inner shadows.

Keep reading

Related tools

Written by Mian Ali Khalid. More guides in Frontend & Design.