skills/performance-analyzer/SKILL.md
CSS performance analysis covering bundle size, selector complexity, render-blocking resources, critical CSS, and optimization strategies. Use when CSS performance is slow or bundle size is too large.
npx skillsauth add andronics/claude-plugin-css-pro performance-analyzerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill analyzes CSS performance and identifies optimization opportunities. I'll examine bundle size, selector efficiency, render performance, and suggest specific improvements to make your CSS faster.
First Contentful Paint (FCP)
Largest Contentful Paint (LCP)
Cumulative Layout Shift (CLS)
CSS Bundle Size
Unused CSS
# Check CSS file sizes
ls -lh dist/*.css
# Example output:
# styles.css 250KB (uncompressed)
# styles.min.css 180KB (minified)
# styles.min.css.gz 45KB (gzipped)
Original: 250KB (100%)
Minified: 180KB (72%) - Remove whitespace, comments
Gzipped: 45KB (18%) - Compression
Unused removed: 30KB (12%) - Remove unused CSS
Optimized: 30KB (12%) - Final target
Potential savings: 88%
Analyze what's in your bundle:
Vendor CSS (Bootstrap, etc.): 120KB (48%)
Component styles: 80KB (32%)
Utility classes: 30KB (12%)
Global styles: 20KB (8%)
Recommendations:
1. Remove unused Bootstrap components
2. Use PurgeCSS for utilities
3. Split vendor from custom CSS
/* ❌ VERY SLOW - Universal selector with pseudo */
*:hover {
cursor: pointer;
}
/* ❌ SLOW - Descendant with universal */
.container * {
box-sizing: border-box;
}
/* ❌ SLOW - Complex attribute selectors */
[class^="icon-"][class$="-large"] {
font-size: 2rem;
}
/* ❌ SLOW - Deep nesting */
.nav ul li a span.icon {
color: blue;
}
/* ✓ FAST - Single class */
.icon-large {
font-size: 2rem;
}
/* ✓ FAST - Low specificity */
.nav-icon {
color: blue;
}
Complexity Score (Lower is better):
Single class: 1 point (.button)
Element selector: 1 point (div)
Class + element: 2 points (div.button)
Descendant: +1 per level (.nav .item .link = 3)
Pseudo-class: +1 (:hover)
Attribute: +2 ([type="text"])
Complex attribute: +3 ([class*="btn-"])
Universal: +5 (*)
Target: Average < 5 points per selector
/* BEFORE: Complexity 8 */
.container .sidebar nav ul li a:hover {
color: blue;
}
/* Score: 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8 */
/* AFTER: Complexity 2 */
.sidebar-link:hover {
color: blue;
}
/* Score: 1 + 1 = 2 */
/* BEFORE: Complexity 10 */
div[class^="card-"][class$="-featured"]:not(.disabled) {
border: 2px solid gold;
}
/* Score: 1 + 3 + 3 + 2 + 1 = 10 */
/* AFTER: Complexity 1 */
.card--featured {
border: 2px solid gold;
}
/* Score: 1 */
/* ❌ EXPENSIVE - Triggers layout recalculation */
.animated {
animation: move 1s;
}
@keyframes move {
from { left: 0; width: 100px; }
to { left: 100px; width: 200px; }
}
/* These properties trigger layout:
* width, height, padding, margin, border
* top, right, bottom, left
* font-size, line-height
* display, position, float
*/
/* ⚠️ MODERATE - Triggers repaint */
.animated {
animation: fade 1s;
}
@keyframes fade {
from { background: red; }
to { background: blue; }
}
/* These properties trigger paint:
* color, background, box-shadow
* border-radius, border-style
* visibility, outline
*/
/* ✓ OPTIMAL - GPU accelerated */
.animated {
animation: slide 1s;
}
@keyframes slide {
from { transform: translateX(0); opacity: 0; }
to { transform: translateX(100px); opacity: 1; }
}
/* These are compositor-only:
* transform (translate, rotate, scale)
* opacity
*/
/* ❌ POOR PERFORMANCE */
@keyframes slideIn {
from { left: -100px; } /* Triggers layout */
to { left: 0; }
}
/* Performance impact:
* - Recalculates layout (expensive)
* - Repaints (expensive)
* - Composites (cheap)
* Total: ~50ms per frame
* Result: Janky animation < 60fps
*/
/* ✓ GOOD PERFORMANCE */
@keyframes slideIn {
from { transform: translateX(-100px); } /* Compositor only */
to { transform: translateX(0); }
}
/* Performance impact:
* - Composites (cheap)
* Total: ~1-2ms per frame
* Result: Smooth animation @ 60fps
*/
CSS required for above-the-fold content. Should be inlined in <head> to eliminate render-blocking requests.
/* CRITICAL - Above the fold */
/* Inline these in <head> */
/* Reset */
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 0;
font-family: system-ui;
}
/* Header (visible immediately) */
.header {
display: flex;
padding: 1rem;
background: white;
}
.logo {
font-size: 1.5rem;
}
.nav {
display: flex;
gap: 1rem;
}
/* Hero section (above fold) */
.hero {
min-height: 400px;
padding: 4rem 2rem;
background: #f0f0f0;
}
.hero-title {
font-size: 3rem;
margin: 0;
}
/* NON-CRITICAL - Load async */
/* Footer, modals, below-fold content */
<!DOCTYPE html>
<html>
<head>
<!-- INLINE CRITICAL CSS -->
<style>
/* Critical CSS here (< 14KB) */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui; }
.header { /* ... */ }
.hero { /* ... */ }
</style>
<!-- PRELOAD FULL STYLESHEET -->
<link rel="preload" href="/styles.css" as="style">
<!-- LOAD FULL STYLESHEET ASYNC -->
<link rel="stylesheet" href="/styles.css" media="print" onload="this.media='all'">
<noscript><link rel="stylesheet" href="/styles.css"></noscript>
</head>
<body>
<!-- Content -->
</body>
</html>
/* ❌ POOR - Single large bundle, render-blocking */
<link rel="stylesheet" href="/styles.css"> <!-- 250KB -->
/* Issues:
* - Blocks rendering until entire file downloads
* - Contains unused CSS
* - No prioritization
*/
/* ✓ BETTER - Critical CSS inline + async full */
<style>/* Critical CSS */</style>
<link rel="preload" href="/styles.css" as="style">
<link rel="stylesheet" href="/styles.css" media="print" onload="this.media='all'">
/* Benefits:
* - Immediate rendering with critical CSS
* - Non-blocking full stylesheet load
* - Faster FCP
*/
/* ✓ BEST - Critical inline + route-based splitting */
<style>/* Critical CSS */</style>
<link rel="preload" href="/common.css" as="style">
<link rel="preload" href="/page.css" as="style">
<link rel="stylesheet" href="/common.css" media="print" onload="this.media='all'">
<link rel="stylesheet" href="/page.css" media="print" onload="this.media='all'">
/* Benefits:
* - Only loads CSS needed for current page
* - Common styles cached across pages
* - Optimal bundle size
*/
<!-- With HTTP/2, can load multiple files efficiently -->
<link rel="stylesheet" href="/reset.css"> <!-- 2KB -->
<link rel="stylesheet" href="/typography.css"> <!-- 5KB -->
<link rel="stylesheet" href="/layout.css"> <!-- 8KB -->
<link rel="stylesheet" href="/components.css"> <!-- 15KB -->
<!-- Advantages:
* Better caching (only changed files re-download)
* Parallel loading
* Selective loading possible
-->
# CSS Stats - Analyze CSS complexity
npx cssstats styles.css > stats.json
# Coverage - Find unused CSS (Chrome DevTools)
# DevTools → Coverage → Record → Reload
# Lighthouse - Performance audit
lighthouse https://example.com --only-categories=performance
# Bundle analyzer
npx webpack-bundle-analyzer stats.json
# Minification - Remove whitespace
npx cssnano styles.css styles.min.css
# PurgeCSS - Remove unused CSS
npx purgecss --css styles.css --content '**/*.html' --output dist/
# Critical - Extract critical CSS
npx critical index.html --base dist --inline > optimized.html
# Compression - Gzip/Brotli
gzip -9 styles.css # Gzip
brotli -q 11 styles.css # Brotli (better)
# performance-budget.yml
# Bundle sizes
css-total: 50KB # Total CSS (gzipped)
css-critical: 14KB # Inline critical CSS
css-vendor: 20KB # Third-party CSS
# Metrics
first-contentful-paint: 1.8s
largest-contentful-paint: 2.5s
cumulative-layout-shift: 0.1
# Code quality
unused-css: 20% # Max unused CSS
avg-selector-depth: 3 # Max avg nesting
specificity-avg: 30 # Max avg specificity
# Add to CI/CD pipeline
npm run build
npm run analyze-bundle
# Check if bundle exceeds budget
if [ $(stat -f%z dist/styles.css.gz) -gt 51200 ]; then
echo "❌ CSS bundle exceeds 50KB limit"
exit 1
fi
Input: Analyze styles.css (250KB)
Report:
# CSS Performance Analysis
## Bundle Size 🔴
- **Uncompressed**: 250KB
- **Minified**: 180KB (28% savings)
- **Gzipped**: 45KB (82% total savings)
- **Status**: ❌ Exceeds 50KB budget
### Recommendations:
1. Remove unused CSS (estimated 70KB savings)
2. Split vendor CSS (Bootstrap) from custom
3. Implement code splitting by route
## Selector Performance ⚠️
- **Average depth**: 4.2 levels
- **Complex selectors**: 23 found
- **Universal selectors**: 5 found
### Top Issues:
1. `.container * { }` - Universal descendant (line 45)
2. `#nav ul li a span` - 5 levels deep (line 234)
3. `[class*="btn-"]:not(.disabled)` - Complex attribute (line 567)
### Recommendations:
1. Refactor to BEM methodology
2. Replace universal selectors with specific classes
3. Flatten deeply nested selectors
## Render Performance ✓
- **Layout-triggering animations**: 2 found
- **Paint-heavy properties**: 15 instances
- **Compositor-only**: 8 animations
### Issues:
1. `@keyframes slideIn` uses `left` property (line 890)
- **Fix**: Use `transform: translateX()`
2. `.animated` animates `width` (line 923)
- **Fix**: Use `transform: scaleX()`
## Critical CSS ⚠️
- **Above-fold CSS**: ~35KB
- **Currently inline**: 0KB
- **Render-blocking**: Yes
### Recommendations:
1. Extract critical CSS (header, hero, navigation)
2. Inline critical CSS (target < 14KB)
3. Load remaining CSS async
## Priority Actions:
1. 🔴 **HIGH**: Remove unused CSS (↓ 70KB)
2. 🟠 **MEDIUM**: Inline critical CSS (improve FCP by ~1s)
3. 🟡 **LOW**: Refactor selectors (improve maintainability)
## Expected Impact:
- Bundle size: 250KB → 50KB (80% reduction)
- FCP: 3.2s → 1.5s (53% improvement)
- LCP: 4.5s → 2.2s (51% improvement)
Request performance analysis:
I'll provide actionable optimization recommendations!
tools
Responsive design assistance including breakpoint generation, fluid typography, container queries, and mobile-first/desktop-first strategy guidance. Use when creating responsive layouts or adapting designs for multiple screen sizes.
development
Interactive Flexbox and Grid layout generator with real-time code output. Creates production-ready layouts based on your requirements with proper fallbacks and responsive considerations. Use when building layouts, grids, or complex positioning systems.
development
Design token management for creating, organizing, and applying design tokens across projects. Supports multiple formats (CSS custom properties, Sass, JS, JSON). Use when setting up design systems or managing design tokens.
tools
Deep CSS analysis tool for understanding specificity, cascade order, inheritance chains, and computed styles. Visualizes CSS complexity and suggests simplifications. Use when debugging specificity issues or understanding CSS behavior.