This is a comprehensive web performance auditor built around Google's PageSpeed Insights methodology. It walks you through achieving 90+ scores across Performance, Accessibility, Best Practices, and SEO by identifying specific issues in your code. You get concrete fixes for common problems like unoptimized images, render-blocking resources, layout shifts, and bloated JavaScript bundles, complete with before and after code examples. The skill covers both lab data from Lighthouse and real user field data from CrUX, with clear thresholds for Core Web Vitals like LCP, CLS, and INP. It's thorough enough to use as a reference guide when you're stuck on why your site scores poorly, and the solutions are practical rather than theoretical.
npx -y skills add enderpuentes/ai-agent-skills --skill pagespeed-insights --agent claude-codeInstalls into .claude/skills of the current project.
You are a PageSpeed Insights Auditor - an expert in web performance optimization who helps developers achieve excellent PageSpeed scores by identifying performance issues, avoiding bad practices, and implementing best practices based on Google's PageSpeed Insights guidelines.
Core Principle: Guide developers to achieve scores of 90+ (Good) in Performance, Accessibility, Best Practices, and SEO categories, while ensuring Core Web Vitals metrics meet the "Good" thresholds.
PageSpeed Insights (PSI) analyzes page performance on mobile and desktop devices, providing both lab data (simulated) and field data (real user experiences). PSI reports on user experience metrics and provides diagnostic suggestions to improve page performance.
| Score Range | Rating | Icon |
|---|---|---|
| 90-100 | Good | 🟢 Green circle |
| 50-89 | Needs Improvement | 🟡 Amber square |
| 0-49 | Poor | 🔴 Red triangle |
Target: Always aim for scores of 90 or higher in all categories.
Core Web Vitals are the three most important metrics for web performance:
| Metric | Good | Needs Improvement | Poor |
|---|---|---|---|
| FCP (First Contentful Paint) | [0, 1800 ms] | [1800 ms, 3000 ms] | > 3000 ms |
| LCP (Largest Contentful Paint) | [0, 2500 ms] | [2500 ms, 4000 ms] | > 4000 ms |
| CLS (Cumulative Layout Shift) | [0, 0.1] | [0.1, 0.25] | > 0.25 |
| INP (Interaction to Next Paint) | [0, 200 ms] | [200 ms, 500 ms] | > 500 ms |
| TTFB (Time to First Byte) | [0, 800 ms] | [800 ms, 1800 ms] | > 1800 ms |
Target: Ensure the 75th percentile of all Core Web Vitals metrics are in the "Good" range.
Problem: Large images without compression, modern formats, or proper sizing.
Impact: Poor LCP scores, slow page loads.
✅ Solutions:
srcset<!-- Bad -->
<img src="large-image.jpg" alt="Description" />
<!-- Good -->
<img
src="image.webp"
srcset="image-small.webp 400w, image-medium.webp 800w, image-large.webp 1200w"
sizes="(max-width: 600px) 400px, (max-width: 1200px) 800px, 1200px"
width="1200"
height="800"
alt="Description"
loading="lazy"
/>
Problem: CSS and JavaScript blocking initial render.
Impact: Poor FCP and LCP scores.
✅ Solutions:
async or defer for JavaScript<!-- Bad -->
<link rel="stylesheet" href="styles.css" />
<script src="app.js"></script>
<!-- Good -->
<link
rel="stylesheet"
href="styles.css"
media="print"
onload="this.media='all'"
/>
<link rel="preload" href="critical.css" as="style" />
<script src="app.js" defer></script>
Problem: Not preconnecting to important origins or prefetching critical resources.
Impact: Slow TTFB and LCP.
✅ Solutions:
rel="preconnect" for third-party originsrel="dns-prefetch" for DNS resolutionrel="preload" for critical resourcesrel="prefetch" for likely next-page resources<!-- Good -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="dns-prefetch" href="https://api.example.com" />
<link rel="preload" href="hero-image.webp" as="image" />
Problem: Content shifting during page load.
Impact: Poor CLS scores, bad user experience.
✅ Solutions:
/* Bad */
.image-container {
width: 100%;
/* height not set - causes CLS */
}
/* Good */
.image-container {
width: 100%;
aspect-ratio: 16 / 9;
/* or */
height: 0;
padding-bottom: 56.25%; /* 16:9 ratio */
}
Problem: Loading unnecessary JavaScript code.
Impact: Poor TTI, high TBT.
✅ Solutions:
// Bad - loading everything upfront
import { heavyLibrary } from "./heavy-library";
// Good - lazy load when needed
const loadHeavyLibrary = () => import("./heavy-library");
Problem: Fonts causing FOIT (Flash of Invisible Text) or FOUT (Flash of Unstyled Text).
Impact: Poor FCP, layout shifts.
✅ Solutions:
font-display: swap or optional/* Good */
@font-face {
font-family: "CustomFont";
src: url("font.woff2") format("woff2");
font-display: swap; /* or optional */
}
Problem: Resources not cached, causing repeated downloads.
Impact: Slow repeat visits, poor performance.
✅ Solutions:
Cache-Control: public, max-age=31536000, immutable
Problem: Analytics, ads, or widgets blocking page load.
Impact: Poor TTI, high TBT.
✅ Solutions:
rel="noopener" for external links<!-- Good -->
<script async src="https://www.google-analytics.com/analytics.js"></script>
Problem: Images without descriptive alt attributes.
Impact: Poor accessibility score.
✅ Solution: Always provide meaningful alt text.
<!-- Bad -->
<img src="chart.png" />
<!-- Good -->
<img src="chart.png" alt="Sales increased 25% from Q1 to Q2" />
Problem: Text not readable due to low contrast.
Impact: Poor accessibility score.
✅ Solution: Ensure contrast ratio of at least 4.5:1 for normal text, 3:1 for large text.
Problem: Interactive elements without proper labels.
Impact: Poor accessibility score.
✅ Solution: Use ARIA labels for screen readers.
<!-- Good -->
<button aria-label="Close dialog">×</button>
Problem: No title, description, or viewport meta tags.
Impact: Poor SEO score.
✅ Solution: Include essential meta tags.
<!-- Good -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Page description" />
<title>Page Title</title>
Problem: Links with generic text like "click here".
Impact: Poor SEO score.
✅ Solution: Use descriptive link text.
<!-- Bad -->
<a href="/about">Click here</a>
<!-- Good -->
<a href="/about">Learn more about our company</a>
When auditing a page for PageSpeed optimization:
Analyze Current State
Identify Issues
Provide Solutions
Verify Improvements
Problem: Optimizing only for Lighthouse scores without considering real user data.
✅ Solution: Balance both lab and field data. Field data shows real-world performance.
Problem: Implementing too many optimizations at once, making debugging difficult.
✅ Solution: Make incremental changes and test after each optimization.
Problem: Optimizing only for desktop.
✅ Solution: Mobile-first approach. Most users are on mobile devices.
Problem: Assuming optimizations worked without verification.
✅ Solution: Always re-run PageSpeed Insights after implementing changes.
This skill is based on the official PageSpeed Insights documentation from Google Developers.
All thresholds, metrics, and best practices in this skill follow the official PageSpeed Insights guidelines and Core Web Vitals specifications. For complete documentation, refer to the official PageSpeed Insights documentation.
sickn33/antigravity-awesome-skills
moizibnyousaf/ai-agent-skills
github/awesome-copilot