This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
WebPerf Snippets is a curated collection of web performance measurement JavaScript snippets designed for use in browser consoles or Chrome DevTools. The project is a documentation website built with Next.js and Nextra, serving as a comprehensive resource for web performance analysis tools.
- Framework: Next.js 13+ with Nextra documentation theme
- Theme: nextra-theme-docs for documentation layout
- Media: Cloudinary integration via next-cloudinary for optimized images/videos
- Deployment: Vercel
- Analytics: Google Analytics and DebugBear monitoring
pages/
βββ _app.js # Next.js app wrapper with analytics scripts
βββ _meta.json # Top-level navigation configuration
βββ index.mdx # Homepage with introduction and video
βββ CoreWebVitals/ # LCP, CLS, and related metrics
β βββ _meta.json
β βββ *.mdx
βββ Loading/ # Resource loading, TTFB, scripts, fonts analysis
β βββ _meta.json
β βββ *.mdx
βββ Interaction/ # User interaction and animation frame metrics
βββ _meta.json
βββ *.mdx
theme.config.jsx # Nextra theme configuration (branding, SEO, footer)
next.config.js # Next.js + Nextra configuration with redirects
The documentation uses Nextra's file-system based routing:
- Each category has its own directory under
pages/ - Individual snippets are documented in
.mdxfiles with executable JavaScript code - Navigation structure is controlled by
_meta.jsonfiles in each directory - All snippets are JavaScript code meant for Chrome DevTools console execution
- theme.config.jsx: Site branding (logo SVG), SEO meta tags, Open Graph settings, footer, sidebar configuration
- pages/_app.js: Next.js app wrapper that includes DebugBear and Google Analytics scripts
- next.config.js: Nextra integration and URL redirects for renamed pages
# Build the production site
npm run build
# Development server (standard Next.js command - not in package.json)
npx next dev
# No tests configured
npm test # Will show error messageWhen working with snippet documentation:
-
Code Blocks: Use the
copyprop in code fences to enable easy copying to DevTools```js copy // snippet code here
-
Snippet Structure: Each snippet should include:
- Clear title and description
- Reference to relevant web.dev documentation for metrics
- Usage instructions
- Executable JavaScript code optimized for Chrome DevTools
-
Performance Context: Snippets focus on measuring:
- Core Web Vitals (LCP, CLS, etc.)
- Resource loading metrics (TTFB, render-blocking resources)
- User interaction and animation frames
- Script and font analysis
-
MDX Features: Pages can import and use:
CldVideoPlayerfrom next-cloudinary for video embeds- Standard React components
- Cloudinary URLs for optimized images
To add a new snippet or category:
- Create the
.mdxfile in the appropriate category directory - Add an entry to the corresponding
_meta.jsonfile with title and ordering - Use kebab-case for file names (e.g.,
LCP-Sub-Parts.mdx) - If creating a redirect for a renamed page, update
next.config.js
Example _meta.json entry:
{
"LCP": {
"title": "LCP"
}
}