performance-optimization
Skill2 starsChanged 6 months agoMITView on GitHub
Frontend performance patterns — Core Web Vitals, bundle optimization, React rendering, lazy loading, memoization. Use when optimizing load times, investigating performance issues, or auditing before launch.
Files
Performance Optimization
Core Web Vitals Targets
| Metric | Good | Needs Work | Poor |
| LCP (Largest Contentful Paint) | ≤ 2.5s | ≤ 4.0s | > 4.0s |
| INP (Interaction to Next Paint) | ≤ 200ms | ≤ 500ms | > 500ms |
| CLS (Cumulative Layout Shift) | ≤ 0.1 | ≤ 0.25 | > 0.25 |
Bundle Optimization
Code Splitting
import { lazy, Suspense } from 'react';
// Route-level splitting (mandatory)
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Settings = lazy(() => import('./pages/Settings'));
// Component-level splitting (for heavy components)
const MarkdownEditor = lazy(() => import('./components/MarkdownEditor'));
const ChartWidget = lazy(() => import('./components/ChartWidget'));
// Always wrap with Suspense + meaningful fallback
<Suspense fallback={<DashboardSkeleton />}>
<Dashboard />
</Suspense>Tree-Shaking
// BAD: imports entire library
import _ from 'lodash';
_.debounce(fn, 300);
// GOOD: imports only what's needed
import debounce from 'lodash/debounce';
debounce(fn, 300);
// BEST: use native or lightweight alternative
function debounce<T extends (...args: unknown[]) => void>(fn: T, ms: number) {
let timer: ReturnType<typeof setTimeout>;
return (...args: Parameters<T>) => {
clearTimeout(timer);
timer = setTimeout(() => fn(...args), ms);
};
}Import Analysis
# Analyze bundle composition
npx vite-bundle-visualizer # Vite
npx @next/bundle-analyzer # Next.js
# Find heavy dependencies
du -sh node_modules/* | sort -rh | head -20React Rendering Optimization
When to Memoize
// MEMOIZE: Expensive computation
const sortedItems = useMemo(
() => items.sort((a, b) => b.date - a.date),
[items]
);
// MEMOIZE: Referential stability for child components
const handleSubmit = useCallback(
(data: FormData) => {
submitMutation.mutate(data);
},
[submitMutation.mutate]
);
// DON'T MEMOIZE: Simple computation
// const fullName = useMemo(() => `${first} ${last}`, [first, last]);
const fullName = `${first} ${last}`; // Just compute it
// DON'T MEMOIZE: Primitive props
// const title = useMemo(() => 'Hello', []);
const title = 'Hello'; // Primitives are already stableRule of thumb: Profile first, memoize second. useMemo/useCallback add complexity — use only when measured impact.
Preventing Unnecessary Re-renders
// BAD: New object every render
<UserCard style={{ marginTop: 16 }} />
// GOOD: Stable reference
const cardStyle = { marginTop: 16 } as const; // Outside component
<UserCard style={cardStyle} />
// BAD: Inline function creates new reference
<List onItemClick={(id) => navigate(`/item/${id}`)} />
// GOOD: Stable callback
const handleItemClick = useCallback(
(id: string) => navigate(`/item/${id}`),
[navigate]
);
<List onItemClick={handleItemClick} />Virtualization for Long Lists
import { useVirtualizer } from '@tanstack/react-virtual';
function VirtualList({ items }: { items: Item[] }) {
const parentRef = useRef<HTMLDivElement>(null);
const virtualizer = useVirtualizer({
count: items.length,
getScrollElement: () => parentRef.current,
estimateSize: () => 64, // Estimated row height
overscan: 5,
});
return (
<div ref={parentRef} className="h-[600px] overflow-auto">
<div style={{ height: `${virtualizer.getTotalSize()}px`, position: 'relative' }}>
{virtualizer.getVirtualItems().map((virtualItem) => (
<div
key={virtualItem.key}
style={{
position: 'absolute',
top: 0,
transform: `translateY(${virtualItem.start}px)`,
height: `${virtualItem.size}px`,
width: '100%',
}}
>
<ItemRow item={items[virtualItem.index]} />
</div>
))}
</div>
</div>
);
}Use virtualization when: List has 100+ items, or items are complex components.
Image Optimization
// Next.js Image (automatic optimization)
import Image from 'next/image';
<Image
src="/hero.jpg"
alt="Hero banner showing the product dashboard"
width={1200}
height={600}
priority // LCP image: preload it
placeholder="blur" // Show blur while loading
/>
// Non-Next.js: native lazy loading
<img
src="/photo.jpg"
alt="Team photo"
loading="lazy" // Browser-native lazy loading
decoding="async" // Non-blocking decode
width={400}
height={300} // Always set dimensions (CLS prevention)
/>Font Loading
/* Preload critical fonts */
<link rel="preload" href="/fonts/inter-var.woff2" as="font" type="font/woff2" crossorigin>
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-var.woff2') format('woff2');
font-display: swap; /* Show fallback immediately, swap when loaded */
font-weight: 100 900;
}Network Performance
// Parallel fetching instead of sequential
// BAD: waterfall
const user = await fetchUser(id);
const posts = await fetchPosts(id);
const comments = await fetchComments(id);
// GOOD: parallel
const [user, posts, comments] = await Promise.all([
fetchUser(id),
fetchPosts(id),
fetchComments(id),
]);
// Prefetching on hover
function NavLink({ href, children }: NavLinkProps) {
const queryClient = useQueryClient();
return (
<Link
href={href}
onMouseEnter={() => {
queryClient.prefetchQuery({
queryKey: ['page', href],
queryFn: () => fetchPageData(href),
});
}}
>
{children}
</Link>
);
}Performance Checklist
- Route-level code splitting for all pages
- Images optimized: lazy loading, proper dimensions, modern formats
- Fonts: preloaded,
font-display: swap - No unnecessary re-renders (profile with React DevTools)
- Long lists virtualized (100+ items)
- API calls parallelized where possible
- Third-party scripts deferred/async
- Bundle analyzed for unnecessary dependencies
- CLS: all images/embeds have dimensions
- LCP element identified and optimized
Integration with Other Skills
- react-patterns: Component structure affects rendering
- state-management: Store selectors prevent re-renders
- css-architecture: CSS strategy affects paint performance
Other versions117 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 117
- addyosmani/agent-skills★ 112ksame name
- sanity-io/sanity★ 6.4ksame name
- gamedev-skills/awesome-gamedev-agent-skills★ 6.4ksame name
- compozy/compozy★ 2.8ksame name
- ollaya-dev/ollaya★ 1.4ksame name
- buddy-compiler/buddy-mlir★ 772same name
- ThibautBaissac/rails_ai_agents★ 665same name
- rizqinrr/viserys-agent★ 556same name
- derHaken/SuperAntigravity★ 439same name
- ukanwat/aaabench★ 399same name
107 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use constraint-driven-development, git-workflow-and-versioning and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MrCipherSmithSkillconstraint-driven-development
Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.
Also in 13 projects that use this
LLl0k0laDSkillgit-workflow-and-versioning
Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
Also in 39 projects that use this
LLl0k0laDSkillusing-agent-skills
Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
Also in 31 projects that use this
HK-hubSkilldeprecation-and-migration
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
Also in 35 projects that use this
ukanwatSkillinput-systems
Architect game input — action mapping (abstracting keys into named actions), rebinding with conflict detection and persistence, multi-device support (keyboard, gamepad, touch), analog deadzones, and feel features like input buffering and coyote time, plus accessibility. Engine-neutral. Use when the user mentions input mapping, rebind controls, gamepad support, deadzone, input buffering, coyote time, or accessible controls.
Also in 4 projects that use this
HK-hubSkillobservability-and-instrumentation
Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.
Also in 26 projects that use this
- +6 more from LLl0k0laD
In this repository18 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- api-layerSkill
- auth-patternsSkill
- core-web-vitalsSkill
- css-architectureSkill
- design-intelligenceSkill
- error-handlingSkill
- frontend-designSkill
- i18nSkill
- monorepo-patternsSkill
- react-patternsSkill
- security-auditSkill
- seo-fundamentalsSkill
- state-managementSkill
- structured-dataSkill
- systematic-debuggingSkill
- testing-strategySkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

