Ship Faster Code, Not Slower Sites
Use AI to automatically monitor performance metrics, run A/B tests between
branches, and get actionable optimization suggestions based on real user data
from Netlify Analytics
Did You Know? Netlify is more than just static hosting! It offers:
- Split Testing for A/B testing branches
- Analytics with Core Web Vitals tracking
- Edge Functions for personalization at the edge
- Build Plugins ecosystem with 100+ integrations
- Forms with built-in spam protection
- Identity for user authentication
- Large Media for Git LFS support
What You’ll Learn
This cookbook teaches you to:- Run A/B tests between branches to measure performance impact
- Monitor Core Web Vitals and build performance metrics
- Automatically block deploys that degrade performance using Deploy Contexts
- Optimize build times with Build Plugins and bundle sizes with AI assistance
Prerequisites
- GitHub repository with a web project
- Netlify account (free tier works)
- Node.js 22+ installed (required for Netlify)
- Continue CLI (
npm i -g @continuedev/cli
) - Netlify MCP configured
- Netlify Development Rules (recommended)
Quick Setup
1
Install Continue CLI
2
Configure Netlify MCP
- Install Netlify CLI:
npm i -g netlify-cli
2. Authenticate with Netlify:netlify login
3. Visit Netlify MCP on Continue Hub 4. Follow the configuration instructions for your editor
3
Add Development Rules
Install the Netlify Development Rules bundle for best practices:
- Visit the bundle page on Continue Hub
- Click “Install Rules”
- Rules automatically apply to your agent
4
Verify Setup
Test the connection with cn CLI:
The Netlify Development Rules bundle includes guardrails for: - Proper
.gitignore
configuration - Function structure and placement - Edge function
constraints - Local development best practicesPerformance Optimization Steps
Step 1: Baseline Performance Metrics
Establish your current performance baseline using cn CLI:Test in Plan Mode First: Before making performance optimizations that
might affect your site, test your prompts in plan mode (see the Plan Mode
Guide; press Shift+Tab to switch modes). This
shows you what the agent will do without executing it. For example:
"Set up A/B testing between main and feature branch with performance monitoring"
Netlify automatically tracks:
- Build Performance: Compile times, cache hits
- Runtime Performance: Core Web Vitals, Time to Interactive
- Resource Usage: Bandwidth, function execution times
Step 2: A/B Test Branch Performance
Compare performance between branches:Enhanced Analytics: Combine Netlify’s A/B testing with PostHog session
recordings to understand not just which variant performs better, but why users
behave differently. See our PostHog session analysis
guide to set up session tracking and
create a complete continuous AI analytics workflow.
Step 3: Advanced Build Optimization with Netlify
Leverage Netlify’s powerful build features to dramatically reduce build times:Netlify Build Features You’re Getting:
- Build Caching - Persist dependencies between builds
- Build Plugins - Extend build process with 100+ plugins
- Conditional Builds - Skip unnecessary builds
- Monorepo Support - Optimize multi-package repos
Discover more optimization prompts! The Netlify community has documented dozens of build optimization strategies in their Support Guide: How can I optimize my Netlify build time.Use this guide as inspiration for cn CLI prompts not covered in this cookbook, such as:
"Configure my builds to skip Dependabot PRs automatically"
"Set up custom ignore patterns for documentation-only changes"
"Optimize my Contentful webhooks to prevent duplicate builds"
"Show me how to use build hooks instead of automatic git triggers"
"Help me choose between Astro and Hugo based on build performance"
Step 4: Bundle Analysis with Netlify’s Built-in Tools
Use Netlify’s bundle analyzer and optimization features:Netlify's Performance Arsenal
Features Available Through Netlify MCP:
- Bundle Analyzer: Visualize your JavaScript bundles
- Asset Optimization: Automatic minification and compression
- Edge Network: Global CDN with smart caching
- Deploy Previews: Test optimizations before production
Step 5: Image Optimization
Optimize images for better performance:Continuous Performance Monitoring
Step 6: Performance Budget Enforcement with Lighthouse CI
Set and enforce performance budgets with automated testing:This comprehensive setup will automatically test every deploy preview and
production deployment, blocking any changes that violate your performance
budgets.
Step 7: Real User Monitoring with Netlify Analytics
Leverage Netlify’s built-in analytics and integrate advanced RUM solutions:Note: Netlify Analytics Pro requires a paid Netlify Pro account ($19/month
per site). The prompt above assumes you have this plan. For free tier users,
focus on steps 2-5 which use Netlify Functions and Edge Functions to build
custom analytics.
Netlify Analytics Advantages:
- Server-side Analytics - No client-side JavaScript needed
- Core Web Vitals - Automatic tracking of Google’s metrics
- Custom Metrics - Track any metric via Functions
- Edge Insights - Geographic performance data
- No Cookie Banner Required - GDPR compliant by default
- Doesn’t slow down your site (server-side)
- Captures 100% of traffic (no ad blockers)
- Respects user privacy (no cookies)
- Shows bot traffic separately
Pro Tip
Combine Netlify Analytics with Edge Functions to create a
powerful RUM solution that:
- Tracks performance by user segment
- A/B tests performance optimizations
- Personalizes content based on connection speed
- Automatically serves lighter assets to slow connections
Automated Performance Checks
GitHub Actions Performance Guard
Block PRs that degrade performance:This workflow will: - Block merge if performance score drops >10 points -
Warn on any performance regression - Celebrate improvements with green
indicators
Performance Testing Locally
Step 8: Local Performance Testing
Test performance before deploying:Step 9: Pre-commit Performance Checks
Prevent performance regressions before they happen:Performance Troubleshooting
Debug Performance Issues
Identify and fix performance bottlenecks:Performance Issue Quick Fixes
Issue | Quick Fix Command (in cn TUI) |
---|---|
Slow LCP | "Preload critical resources" |
High CLS | "Add size attributes to images" |
Large bundles | "Implement code splitting" |
Slow builds | "Enable build caching" |
Poor caching | "Configure cache headers" |
What You’ve Accomplished
Performance-First Development
You’ve built an AI-powered performance optimization system that:
- Automatically monitors Core Web Vitals
- Runs A/B tests between branches
- Blocks deployments that degrade performance
- Provides actionable optimization suggestions
Discover Netlify’s Hidden Performance Gems
Features many developers don’t know Netlify offers:Edge Functions
Netlify Edge Functions
- Run code at the edge, closer to users
- Transform responses on-the-fly
- A/B test at the edge level
- Personalize content without client-side JS
Netlify Graph
Netlify Graph
- Unified GraphQL gateway for all your APIs
- Automatic TypeScript generation
- Built-in authentication handling
- Zero client-side API keys needed
On-Demand Builders
On-Demand
Builders -
Generate pages only when requested - Cache dynamically generated content -
Perfect for large sites (10k+ pages) - Reduce build times dramatically
Netlify Functions
Background Functions
- Run tasks up to 15 minutes
- Process webhooks asynchronously
- Handle heavy computations
- No timeout worries
Performance Best Practices
The Netlify Performance Rules enforce:Build Optimization
- Dependency caching enabled
- Parallel builds when possible
- Incremental compilation
- Smart cache invalidation
Runtime Performance
- Automatic image optimization
- Efficient resource hints (preload, prefetch)
- Optimal cache headers
- CDN configuration
Monitoring Standards
- Performance budgets enforced
- Core Web Vitals tracking
- Real user monitoring
- Automated alerts
Advanced Performance Strategies
Progressive Enhancement
Multi-variant Testing
Predictive Prefetching
Next Steps
- Install Netlify MCP from Continue Hub
- Set up Performance Monitoring
- Configure A/B Testing
- Join the Continue Discord for support