Web Performance & Core Web Vitals
Overview
Enforces high-efficiency frontend and full-stack performance standards to achieve exceptional Core Web Vitals: Largest Contentful Paint (LCP < 2.5s), Interaction to Next Paint (INP < 200ms), and Cumulative Layout Shift (CLS < 0.1).
When to Use
Activate whenever analyzing, profiling, writing, or optimizing page loading speeds, network waterfalls, script bundling, animation frame rates, or data caching.
Negative Constraints (What NOT to Do)
- NEVER introduce async waterfalls: Do not chain sequential
await calls when requests can be executed concurrently via Promise.all().
- NEVER import large full libraries when only a utility is needed: Never
import _ from 'lodash'; use import debounce from 'lodash/debounce' or native alternatives.
- NEVER render images or videos without explicit aspect ratios: Always provide
width and height or aspect-ratio to avoid Cumulative Layout Shift (CLS).
- NEVER trigger synchronous layout thrashing: Do not alternate between reading layout properties (
offsetHeight, getBoundingClientRect) and writing styles in loops.
- NEVER animate non-composited properties: Animate only GPU-composited CSS properties (
transform, opacity). Never animate width, height, top, left, or margin.
Rules & Patterns
1. Vercel Optimization Hierarchy by Impact
| Priority |
Category |
Key Optimization Target |
Expected Impact |
| 1. CRITICAL |
Eliminating Waterfalls |
Parallel data fetching (Promise.all), Suspense streaming |
30–60% faster LCP |
| 2. CRITICAL |
Bundle Size Optimization |
Direct submodule imports, next/dynamic, deferring 3rd party scripts |
40–70% smaller initial JS |
| 3. HIGH |
Server-Side & RSC Caching |
React.cache() request deduplication, edge SSR caching |
Lower TTFB & DB load |
| 4. MEDIUM-HIGH |
Client Query Optimization |
SWR / TanStack Query stale-while-revalidate, deduplication |
Zero redundant network calls |
| 5. MEDIUM |
Render & DOM Optimization |
Virtualization for large lists, state colocation, :focus-visible |
Smooth 60 FPS / INP < 100ms |
2. Eliminating Network Waterfalls
// [GOOD] Parallel execution
const [user, notifications] = await Promise.all([
fetchUser(),
fetchNotifications(),
]);
const posts = await fetchPosts(user.id);
3. Layout Shift & Visual Stability (CLS < 0.1)
- Images & Video: Always supply
width, height, and sizes or CSS aspect-ratio: 16 / 9.
- Dynamic Content: Reserve layout space for dynamically loaded widgets with min-height placeholders or skeletons.
- Tabular Numbers: Use
font-feature-settings: "tnum" / font-variant-numeric: tabular-nums for counters, clocks, and tables to prevent number width jitter.
Code Examples
See EXAMPLES.md for detailed performance patterns and benchmark snippets.
Validation Checklist
Common Mistakes
- Chaining independent async requests instead of using
Promise.all.
- Animating layout-triggering properties (
height, width, top) causing jank.
- Missing image dimensions causing layout shift when images finish loading.
Integration Notes
- Pairs with
nextjs and react for App Router caching and component lifecycle tuning.
- Pairs with
ui-ux-pro for smooth animations and responsive design tokens.
1---2name: web-performance-23description: ContextOS skill for Web Performance, Core Web Vitals, waterfall elimination, bundle size optimization, and caching strategies.4---56# Web Performance & Core Web Vitals78## Overview910Enforces high-efficiency frontend and full-stack performance standards to achieve exceptional Core Web Vitals: Largest Contentful Paint (LCP < 2.5s), Interaction to Next Paint (INP < 200ms), and Cumulative Layout Shift (CLS < 0.1).1112## When to Use1314Activate whenever analyzing, profiling, writing, or optimizing page loading speeds, network waterfalls, script bundling, animation frame rates, or data caching.1516## Negative Constraints (What NOT to Do)17181. **NEVER introduce async waterfalls**: Do not chain sequential `await` calls when requests can be executed concurrently via `Promise.all()`.192. **NEVER import large full libraries when only a utility is needed**: Never `import _ from 'lodash'`; use `import debounce from 'lodash/debounce'` or native alternatives.203. **NEVER render images or videos without explicit aspect ratios**: Always provide `width` and `height` or `aspect-ratio` to avoid Cumulative Layout Shift (CLS).214. **NEVER trigger synchronous layout thrashing**: Do not alternate between reading layout properties (`offsetHeight`, `getBoundingClientRect`) and writing styles in loops.225. **NEVER animate non-composited properties**: Animate only GPU-composited CSS properties (`transform`, `opacity`). Never animate `width`, `height`, `top`, `left`, or `margin`.2324## Rules & Patterns2526### 1. Vercel Optimization Hierarchy by Impact2728| Priority | Category | Key Optimization Target | Expected Impact |29|:---|:---|:---|:---|30| **1. CRITICAL** | **Eliminating Waterfalls** | Parallel data fetching (`Promise.all`), Suspense streaming | **30–60% faster LCP** |31| **2. CRITICAL** | **Bundle Size Optimization** | Direct submodule imports, `next/dynamic`, deferring 3rd party scripts | **40–70% smaller initial JS** |32| **3. HIGH** | **Server-Side & RSC Caching** | `React.cache()` request deduplication, edge SSR caching | **Lower TTFB & DB load** |33| **4. MEDIUM-HIGH** | **Client Query Optimization** | SWR / TanStack Query stale-while-revalidate, deduplication | **Zero redundant network calls** |34| **5. MEDIUM** | **Render & DOM Optimization** | Virtualization for large lists, state colocation, `:focus-visible` | **Smooth 60 FPS / INP < 100ms** |3536### 2. Eliminating Network Waterfalls3738```ts39// [GOOD] Parallel execution40const [user, notifications] = await Promise.all([41 fetchUser(),42 fetchNotifications(),43]);44const posts = await fetchPosts(user.id);45```4647### 3. Layout Shift & Visual Stability (CLS < 0.1)4849- **Images & Video**: Always supply `width`, `height`, and `sizes` or CSS `aspect-ratio: 16 / 9`.50- **Dynamic Content**: Reserve layout space for dynamically loaded widgets with min-height placeholders or skeletons.51- **Tabular Numbers**: Use `font-feature-settings: "tnum"` / `font-variant-numeric: tabular-nums` for counters, clocks, and tables to prevent number width jitter.5253## Code Examples5455See `EXAMPLES.md` for detailed performance patterns and benchmark snippets.5657## Validation Checklist5859- [ ] LCP target is < 2.5s with preloaded critical fonts and LCP image `priority`.60- [ ] No sequential `await` waterfalls in API routes or Server Components.61- [ ] All animated elements use only `transform` and `opacity`.62- [ ] `prefers-reduced-motion` media queries are respected.63- [ ] Large tables / lists (> 100 items) utilize virtualization.6465## Common Mistakes6667- Chaining independent async requests instead of using `Promise.all`.68- Animating layout-triggering properties (`height`, `width`, `top`) causing jank.69- Missing image dimensions causing layout shift when images finish loading.7071## Integration Notes7273- Pairs with `nextjs` and `react` for App Router caching and component lifecycle tuning.74- Pairs with `ui-ux-pro` for smooth animations and responsive design tokens.