0
0
Tailwindmarkup~8 mins

Box shadow utilities in Tailwind - Performance & Optimization

Choose your learning style9 modes available
Performance: Box shadow utilities
MEDIUM IMPACT
Box shadow utilities affect the paint and composite stages of page rendering, impacting how quickly shadows appear and how smoothly the page scrolls or animates.
Applying shadows to many elements on a page
Tailwind
class="shadow-sm" applied selectively to key elements only
Simpler shadows with smaller blur radius reduce paint cost and limit compositing layers.
📈 Performance Gainreduces paint time and composite layers, improving frame rate and interaction smoothness
Applying shadows to many elements on a page
Tailwind
class="shadow-[0_0_20px_10px_rgba(0,0,0,0.5)]" applied to 100+ elements
Complex shadows with large blur and spread on many elements cause heavy paint and composite work.
📉 Performance Costtriggers multiple paint and composite layers, increasing frame time and causing jank
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Heavy custom shadows on many elementsLow0High (many pixels to paint)[X] Bad
Simple Tailwind shadow utilities on few elementsLow0Low (small shadow area)[OK] Good
Rendering Pipeline
Box shadows are calculated during style calculation, then cause extra paint and composite layers because shadows extend beyond element bounds.
Style Calculation
Paint
Composite
⚠️ BottleneckPaint and Composite stages are most expensive due to shadow rendering and layer creation.
Core Web Vital Affected
INP
Box shadow utilities affect the paint and composite stages of page rendering, impacting how quickly shadows appear and how smoothly the page scrolls or animates.
Optimization Tips
1Limit box shadow complexity to reduce paint and composite cost.
2Avoid applying shadows to many elements simultaneously.
3Prefer Tailwind's predefined shadow utilities for balanced performance.
Performance Quiz - 3 Questions
Test your performance knowledge
Which box shadow usage will most likely cause slower page interaction?
ANot using any shadows at all
BApplying large, blurred shadows to many elements
CUsing small, subtle shadows on a few elements
DUsing shadows only on static images
DevTools: Performance
How to check: Record a performance profile while interacting with the page, then look for long paint or composite events related to shadow rendering.
What to look for: Look for high paint times and many composite layers caused by box shadows to identify performance bottlenecks.