performance-optimization

performance-optimization is a cursor rule for Cursor from Farzannajipour/cursor-react-rules. It costs 0 tokens per session (813 once invoked), scanned A, original, MIT.

A set of coding rules for making React applications use fewer resources and respond faster, covering rendering, loading, lists, and images.

In plain words
What is it for?
Use it when reviewing React performance, choosing memoization, splitting or delaying code, rendering large lists, optimizing images, and avoiding common browser bottlenecks.
Why use it?
It helps reduce unnecessary component updates, avoid loading large code before it is needed, and keep long lists from slowing down the page.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when reviewing React performance, choosing memoization, splitting or delaying code, rendering large lists, optimizing images, and avoiding common browser bottlenecks.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/farzannajipour/cursor-react-rules/performance-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/Farzannajipour/cursor-react-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for performance-optimization

README.md
[![agentmods](https://agentmods.dev/badge/rules/farzannajipour/cursor-react-rules/performance-optimization/github.svg)](https://agentmods.dev/rules/farzannajipour/cursor-react-rules/performance-optimization)
Your own site
<a href="https://agentmods.dev/rules/farzannajipour/cursor-react-rules/performance-optimization"><img src="https://agentmods.dev/badge/rules/farzannajipour/cursor-react-rules/performance-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for performance-optimization

Your own site · 80×15
<a href="https://agentmods.dev/rules/farzannajipour/cursor-react-rules/performance-optimization"><img src="https://agentmods.dev/badge/rules/farzannajipour/cursor-react-rules/performance-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 813 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00813
Opus 5.5 $0.00000 $0.00325
Sonnet 5.5 $0.00000 $0.00163
Haiku 4.5 $0.00000 $0.00081

Measured 1mo ago against content hash fb59857d0c22, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

performance-optimization scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

fetch(url, {
.cursor/rules/performance-optimization.mdc · 152 lines

How it starts

The opening of the file, as written. The whole thing — 152 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Performance Optimization Patterns

React Performance Rules

1. Memoization

Use React.memo() for expensive pure components:

export const ExpensiveComponent = memo<Props>(({ data }) => {
  return <div>{/* expensive rendering */}</div>;
});

Use useMemo() for expensive calculations:

const sortedData = useMemo(() => {
  return data.sort((a, b) => a.value - b.value);
}, [data]);

Use useCallback() for function props:

const handleClick = useCallback((id: string) => {
  // handler logic
}, []);

2. Code Splitting

Use React.lazy() for route-based splitting:

const Dashboard = lazy(() => import('@/components/Dashboard'));

<Suspense fallback={<Loading />}>
  <Dashboard />
</Suspense>

Use dynamic imports for large libraries:

// Only load when needed
const loadChart = async () => {
  const Chart = await import('chart.js');
  return Chart;
};

3. List Optimization

Always use stable keys:

// ✅ Good - stable ID
{items.map(item => <Item key={item.id} {...item} />)}

// ❌ Bad - index as key
{items.map((item, i) => <Item key={i} {...item} />)}

Virtualize long lists:

import { useVirtualizer } from '@tanstack/react-virtual';

const virtualizer = useVirtualizer({
  count: items.length,
  getScrollElement: () => parentRef.current,
  estimateSize: () => 50,
});

Next.js Specific Optimizations

Image Optimization

import Image from 'next/image';

// Use priority for above-the-fold images
<Image src="/hero.jpg" alt="Hero" width={1200} height={600} priority />

// Lazy load below-the-fold
<Image src="/product.jpg" alt="Product" width={400} height={400} loading="lazy" />

Font Optimization

import { Inter } from 'next/font/google';

const inter = Inter({ subsets: ['latin'], display: 'swap' });

<main className={inter.className}>{children}</main>

Caching Strategies

// Static Generation with revalidation
export const revalidate = 3600; // 1 hour

// Fetch with caching
fetch(url, {
  next: { revalidate: 3600, tags: ['posts'] }
});

Read the full file on GitHub · 152 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 152 lines · 0 tokens per session scan A fb59857d0c22

Subscribe to this mod's changes

performance-optimization is a cursor rule published in the GitHub repository Farzannajipour/cursor-react-rules (3 stars, last pushed 8mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 813 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.