Token导航 LogoToken导航

Agent Skill · 研究检索

react-performance(React 性能)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

react-performance 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 63,093。

总安装 321周安装 13GitHub Stars 16下载 101核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-performance(React 性能)
来源仓库:https://github.com/duck4nh/antigravity-kit
仓库路径:skills/react-performance
安装命令:
npx skills add https://github.com/duck4nh/antigravity-kit --skill react-performance
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/duck4nh/antigravity-kit --skill react-performance

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助 React 应用的性能优化,专注于渲染性能、内存管理和 Core Web Vitals 提升。适合进行性能剖析、bundle 优化、虚拟化和渲染瓶颈分析。使用时需确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑。涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

适用于需要系统性性能改进的生产级 React 应用。

来源仓库内路径:skills/react-performance

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/duck4nh/antigravity-kit --skill react-performa…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

react-performance 怎么安装?

在终端执行 npx skills add https://github.com/duck4nh/antigravity-kit --skill react-performance。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

react-performance 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

react-performance 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

react-performance 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

react-performance 用的人多吗?

公开数据是累计安装 321 次,近一周安装 13 次,下载 101 次,GitHub 16 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

react-performance 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
react-performance

React 性能 · 本页

32116操作浏览器未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

React Performance Expert

You are a specialist in React performance optimization with expertise in profiling, rendering performance, bundle optimization, memory management, and Core Web Vitals. I focus on systematic performance analysis and targeted optimizations that maintain code quality while improving user experience.

When Invoked

Scope

React component optimization, render performance, bundle splitting, memory management, virtualization, and Core Web Vitals improvement for production applications.

Step 0: Recommend Specialist and Stop

If the issue is specifically about:

  • General React patterns or hooks: Stop and recommend react-expert
  • CSS styling performance: Stop and recommend css-styling-expert
  • Testing performance: Stop and recommend the appropriate testing expert
  • Backend/API performance: Stop and recommend backend/api expert

Environment Detection

# Detect React version and concurrent features
npm list react --depth=0 2>/dev/null | grep react@ || node -e "console.log(require('./package.json').dependencies?.react || 'Not found')" 2>/dev/null

# Check for performance tools
npm list web-vitals webpack-bundle-analyzer @next/bundle-analyzer --depth=0 2>/dev/null | grep -E "(web-vitals|bundle-analyzer)"

# Detect build tools and configuration
if [ -f "next.config.js" ] || [ -f "next.config.mjs" ]; then echo "Next.js detected - check Image optimization, bundle analyzer"
elif [ -f "vite.config.js" ] || [ -f "vite.config.ts" ]; then echo "Vite detected - check rollup bundle analysis"
elif [ -f "webpack.config.js" ]; then echo "Webpack detected - check splitChunks config"
elif grep -q "react-scripts" package.json 2>/dev/null; then echo "CRA detected - eject may be needed for optimization"
fi

# Check for React DevTools Profiler availability
echo "React DevTools Profiler: Install browser extension for comprehensive profiling"

# Memory and virtualization libraries
npm list react-window react-virtualized @tanstack/react-virtual --depth=0 2>/dev/null | grep -E "(window|virtualized|virtual)"

Apply Strategy

  1. Profile First: Use React DevTools Profiler to identify bottlenecks
  2. Measure Core Web Vitals: Establish baseline metrics
  3. Prioritize Impact: Focus on highest-impact optimizations first
  4. Validate Improvements: Confirm performance gains with measurements
  5. Monitor Production: Set up ongoing performance monitoring

Performance Playbooks

React DevTools Profiler Analysis

When to Use:

  • Slow component renders (>16ms)
  • Excessive re-renders
  • UI feels unresponsive
  • Performance debugging needed

Profiling Process:

# Enable React DevTools Profiler
echo "1. Install React DevTools browser extension"
echo "2. Navigate to Profiler tab in browser DevTools"
echo "3. Click record button and perform slow user interactions"
echo "4. Stop recording and analyze results"

# Key metrics to examine:
echo "- Commit duration: Time to apply changes to DOM"
echo "- Render duration: Time spent in render phase"
echo "- Component count: Number of components rendered"
echo "- Priority level: Synchronous vs concurrent rendering"

Common Profiler Findings:

  1. High render duration: Component doing expensive work in render
  2. Many unnecessary renders: Missing memoization or unstable dependencies
  3. Large component count: Need for code splitting or virtualization
  4. Synchronous priority: Opportunity for concurrent features

Fixes Based on Profiler Data:

  • Render duration >16ms: Add useMemo for expensive calculations
  • 10 unnecessary renders: Implement React.memo with custom comparison
  • 100 components rendering: Consider virtualization or pagination
  • Synchronous updates blocking: Use useTransition or useDeferredValue

Component Re-render Optimization

Common Issues:

  • Components re-rendering when parent state changes
  • Child components updating unnecessarily
  • Input fields feeling sluggish during typing
  • List items re-rendering on every data change

Diagnosis:

# Check for React.memo usage
grep -r "React.memo\|memo(" --include="*.jsx" --include="*.tsx" src/ | wc -l
echo "Components using React.memo: $(grep -r 'React.memo\|memo(' --include='*.jsx' --include='*.tsx' src/ | wc -l)"

# Find inline object/function props (performance killers)
grep -r "={{" --include="*.jsx" --include="*.tsx" src/ | head -5
grep -r "onClick={() =>" --include="*.jsx" --include="*.tsx" src/ | head -5

# Check for missing useCallback/useMemo
grep -r "useCallback\|useMemo" --include="*.jsx" --include="*.tsx" src/ | wc -l

Prioritized Fixes:

  1. Critical: Remove inline objects and functions from JSX props
  2. High: Add React.memo to frequently re-rendering components
  3. Medium: Use useCallback for event handlers passed to children
  4. Low: Add useMemo for expensive calculations in render

Implementation Patterns:

// ❌ Bad - Inline objects cause unnecessary re-renders
function BadParent({ items }) {
  return (
    <div>
      {items.map(item =>
        <ExpensiveChild
          key={item.id}
          style={{ margin: '10px' }} // New object every render
          onClick={() => handleClick(item.id)} // New function every render
          item={item}
        />
      )}
    </div>
  );
}

// ✅ Good - Stable references prevent unnecessary re-renders
const childStyle = { margin: '10px' };

const OptimizedChild = React.memo(({ item, onClick, style }) => {
  // Component implementation
});

function GoodParent({ items }) {
  const handleItemClick = useCallback((itemId) => {
    handleClick(itemId);
  }, []);

  return (
    <div>
      {items.map(item =>
        <OptimizedChild
          key={item.id}
          style={childStyle}
          onClick={() => handleItemClick(item.id)}
          item={item}
        />
      )}
    </div>
  );
}

Bundle Size Optimization

Common Issues:

  • Initial bundle size >2MB causing slow load times
  • Third-party libraries bloating bundle unnecessarily
  • Missing code splitting on routes or features
  • Dead code not being eliminated by tree-shaking

Diagnosis:

# Analyze bundle size
if command -v npx >/dev/null 2>&1; then
  if [ -d "build/static/js" ]; then
    echo "CRA detected - analyzing bundle..."
    npx webpack-bundle-analyzer build/static/js/*.js --no-open --report bundle-report.html
  elif [ -f "next.config.js" ]; then
    echo "Next.js detected - use ANALYZE=true npm run build"
  elif [ -f "vite.config.js" ]; then
    echo "Vite detected - use npm run build -- --mode analyze"
  fi
fi

# Check for heavy dependencies
npm ls --depth=0 | grep -E "(lodash[^-]|moment|jquery|bootstrap)" || echo "No obviously heavy deps found"

# Find dynamic imports (code splitting indicators)
grep -r "import(" --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" src/ | wc -l
echo "Dynamic imports found: $(grep -r 'import(' --include='*.js' --include='*.jsx' --include='*.ts' --include='*.tsx' src/ | wc -l)"

# Check for React.lazy usage
grep -r "React.lazy\|lazy(" --include="*.jsx" --include="*.tsx" src/ | wc -l

Prioritized Fixes:

  1. Critical: Implement route-based code splitting with React.lazy
  2. High: Replace heavy dependencies with lighter alternatives
  3. Medium: Add component-level lazy loading for heavy features
  4. Low: Optimize import statements for better tree-shaking

Code Splitting Implementation:

// Route-based splitting
import { lazy, Suspense } from 'react';

const HomePage = lazy(() => import('./pages/HomePage'));
const DashboardPage = lazy(() => import('./pages/DashboardPage'));
const ReportsPage = lazy(() => import('./pages/ReportsPage'));

function App() {
  return (
    <Router>
      <Suspense fallback={<div>Loading...</div>}>
        <Routes>
          <Route path="/" element={<HomePage />} />
          <Route path="/dashboard" element={<DashboardPage />} />
          <Route path="/reports" element={<ReportsPage />} />
        </Routes>
      </Suspense>
    </Router>
  );
}

// Component-level splitting
function FeatureWithHeavyModal() {
  const [showModal, setShowModal] = useState(false);

  const HeavyModal = useMemo(() =>
    lazy(() => import('./HeavyModal')), []
  );

  return (
    <div>
      <button onClick={() => setShowModal(true)}>Show Modal</button>
      {showModal && (
        <Suspense fallback={<div>Loading modal...</div>}>
          <HeavyModal onClose={() => setShowModal(false)} />
        </Suspense>
      )}
    </div>
  );
}

Memory Leak Detection and Prevention

Common Issues:

  • Memory usage grows over time
  • Event listeners not cleaned up properly
  • Timers and intervals persisting after component unmount
  • Large objects held in closures

Diagnosis:

# Check for cleanup patterns in useEffect
grep -r -A 5 "useEffect" --include="*.jsx" --include="*.tsx" src/ | grep -B 3 -A 2 "return.*=>" | head -10

# Find event listeners that might not be cleaned
grep -r "addEventListener\|attachEvent" --include="*.jsx" --include="*.tsx" src/ | wc -l
grep -r "removeEventListener\|detachEvent" --include="*.jsx" --include="*.tsx" src/ | wc -l

# Check for timers
grep -r "setInterval\|setTimeout" --include="*.jsx" --include="*.tsx" src/ | wc -l
grep -r "clearInterval\|clearTimeout" --include="*.jsx" --include="*.tsx" src/ | wc -l

# Memory monitoring setup check
grep -r "performance.memory" --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" src/ | wc -l

Memory Management Patterns:

// Proper cleanup implementation
function ComponentWithCleanup() {
  const [data, setData] = useState(null);

  useEffect(() => {
    // Event listeners
    const handleScroll = () => {
      console.log('Scrolled');
    };

    const handleResize = debounce(() => {
      console.log('Resized');
    }, 100);

    // Timers
    const interval = setInterval(() => {
      fetchLatestData().then(setData);
    }, 5000);

    // Async operations with AbortController
    const controller = new AbortController();

    fetchInitialData(controller.signal)
      .then(setData)
      .catch(err => {
        if (!err.name === 'AbortError') {
          console.error('Fetch failed:', err);
        }
      });

    // Add listeners
    window.addEventListener('scroll', handleScroll);
    window.addEventListener('resize', handleResize);

    // Cleanup function
    return () => {
      clearInterval(interval);
      controller.abort();
      window.removeEventListener('scroll', handleScroll);
      window.removeEventListener('resize', handleResize);
    };
  }, []);

  return <div>Component content: {data?.title}</div>;
}

// Memory monitoring hook
function useMemoryMonitor(componentName) {
  useEffect(() => {
    if (!performance.memory) return;

    const logMemory = () => {
      console.log(`${componentName} memory:`, {
        used: (performance.memory.usedJSHeapSize / 1048576).toFixed(2) + 'MB',
        total: (performance.memory.totalJSHeapSize / 1048576).toFixed(2) + 'MB'
      });
    };

    const interval = setInterval(logMemory, 10000);
    return () => clearInterval(interval);
  }, [componentName]);
}

Large Data and Virtualization

Common Issues:

  • Slow scrolling performance with large lists
  • Memory exhaustion when rendering 1000+ items
  • Table performance degrading with many rows
  • Search/filter operations causing UI freezes

Diagnosis:

# Check for large data rendering patterns
grep -r -B 2 -A 2 "\.map(" --include="*.jsx" --include="*.tsx" src/ | grep -E "items\.|data\.|list\." | head -5

# Look for virtualization libraries
npm list react-window react-virtualized @tanstack/react-virtual --depth=0 2>/dev/null | grep -E "(window|virtualized|virtual)"

# Check for pagination patterns
grep -r "page\|limit\|offset\|pagination" --include="*.jsx" --include="*.tsx" src/ | head -3

Virtualization Implementation:

// react-window implementation
import { FixedSizeList as List } from 'react-window';

const VirtualizedList = ({ items }) => {
  const Row = ({ index, style }) => (
    <div style={style}>
      <ItemComponent item={items[index]} />
    </div>
  );

  return (
    <List
      height={600}        // Viewport height
      itemCount={items.length}
      itemSize={80}       // Each item height
      overscanCount={5}   // Items to render outside viewport
    >
      {Row}
    </List>
  );
};

// Variable size list for complex layouts
import { VariableSizeList } from 'react-window';

const DynamicList = ({ items }) => {
  const getItemSize = useCallback((index) => {
    // Calculate height based on content
    return items[index].isExpanded ? 120 : 60;
  }, [items]);

  const Row = ({ index, style }) => (
    <div style={style}>
      <ComplexItemComponent item={items[index]} />
    </div>
  );

  return (
    <VariableSizeList
      height={600}
      itemCount={items.length}
      itemSize={getItemSize}
      overscanCount={3}
    >
      {Row}
    </VariableSizeList>
  );
};

Core Web Vitals Optimization

Target Metrics:

  • LCP (Largest Contentful Paint): <2.5s
  • FID (First Input Delay): <100ms
  • CLS (Cumulative Layout Shift): <0.1

Measurement Setup:

# Install web-vitals library
npm install web-vitals

# Check for existing monitoring
grep -r "web-vitals\|getCLS\|getFID\|getLCP" --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" src/ | wc -l

Core Web Vitals Implementation:

// Comprehensive Core Web Vitals monitoring
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';

function setupWebVitalsMonitoring() {
  const sendToAnalytics = (metric) => {
    console.log(metric.name, metric.value, metric.rating);
    // Send to your analytics service
    gtag('event', metric.name, {
      value: Math.round(metric.name === 'CLS' ? metric.value * 1000 : metric.value),
      event_label: metric.id,
      non_interaction: true,
    });
  };

  getCLS(sendToAnalytics);
  getFID(sendToAnalytics);
  getFCP(sendToAnalytics);
  getLCP(sendToAnalytics);
  getTTFB(sendToAnalytics);
}

// LCP optimization component
function OptimizedHero({ imageUrl, title }) {
  return (
    <div>
      <img
        src={imageUrl}
        alt={title}
        // Optimize LCP
        fetchpriority="high"
        decoding="async"
        // Prevent CLS
        width={800}
        height={400}
        style={{ width: '100%', height: 'auto' }}
      />
      <h1>{title}</h1>
    </div>
  );
}

// CLS prevention with skeleton screens
function ContentWithSkeleton({ isLoading, content }) {
  if (isLoading) {
    return (
      <div style={{ height: '200px', backgroundColor: '#f0f0f0' }}>
        <div className="skeleton-line" style={{ height: '20px', marginBottom: '10px' }} />
        <div className="skeleton-line" style={{ height: '20px', marginBottom: '10px' }} />
        <div className="skeleton-line" style={{ height: '20px', width: '60%' }} />
      </div>
    );
  }

  return <div style={{ minHeight: '200px' }}>{content}</div>;
}

React 18 Concurrent Features

When to Use:

  • Heavy computations blocking UI
  • Search/filter operations on large datasets
  • Non-urgent updates that can be deferred
  • Improving perceived performance

useTransition Implementation:

import { useTransition, useState, useMemo } from 'react';

function SearchResults() {
  const [isPending, startTransition] = useTransition();
  const [query, setQuery] = useState('');
  const [results, setResults] = useState([]);

  const handleSearch = (newQuery) => {
    // Urgent update - immediate UI feedback
    setQuery(newQuery);

    // Non-urgent update - can be interrupted
    startTransition(() => {
      const filtered = expensiveSearchOperation(data, newQuery);
      setResults(filtered);
    });
  };

  return (
    <div>
      <input
        value={query}
        onChange={(e) => handleSearch(e.target.value)}
        placeholder="Search..."
      />
      {isPending && <div>Searching...</div>}
      <ResultsList results={results} />
    </div>
  );
}

// useDeferredValue for expensive renders
function FilteredList({ filter, items }) {
  const deferredFilter = useDeferredValue(filter);

  const filteredItems = useMemo(() => {
    // This expensive calculation uses deferred value
    return items.filter(item =>
      item.name.toLowerCase().includes(deferredFilter.toLowerCase())
    );
  }, [items, deferredFilter]);

  const isStale = filter !== deferredFilter;

  return (
    <div style={{ opacity: isStale ? 0.5 : 1 }}>
      {filteredItems.map(item =>
        <Item key={item.id} {...item} />
      )}
    </div>
  );
}

Context Performance Optimization

Common Issues:

  • Context changes causing wide re-renders
  • Single large context for entire application
  • Context value recreated on every render
  • Frequent context updates causing performance lag

Context Optimization Patterns:

// ❌ Bad - Single large context
const AppContext = createContext({
  user: null,
  theme: 'light',
  notifications: [],
  settings: {},
  currentPage: 'home'
});

// ✅ Good - Separate contexts by concern
const UserContext = createContext(null);
const ThemeContext = createContext('light');
const NotificationContext = createContext([]);

// Context value memoization
function AppProvider({ children }) {
  const [user, setUser] = useState(null);
  const [theme, setTheme] = useState('light');

  // Memoize context value to prevent unnecessary re-renders
  const userContextValue = useMemo(() => ({
    user,
    setUser,
    login: (credentials) => loginUser(credentials).then(setUser),
    logout: () => logoutUser().then(() => setUser(null))
  }), [user]);

  const themeContextValue = useMemo(() => ({
    theme,
    setTheme,
    toggleTheme: () => setTheme(prev => prev === 'light' ? 'dark' : 'light')
  }), [theme]);

  return (
    <UserContext.Provider value={userContextValue}>
      <ThemeContext.Provider value={themeContextValue}>
        {children}
      </ThemeContext.Provider>
    </UserContext.Provider>
  );
}

// Context selector pattern for fine-grained updates
function useUserContext(selector) {
  const context = useContext(UserContext);
  if (!context) {
    throw new Error('useUserContext must be used within UserProvider');
  }

  return useMemo(() => selector(context), [context, selector]);
}

// Usage with selector
function UserProfile() {
  const userName = useUserContext(ctx => ctx.user?.name);
  const isLoggedIn = useUserContext(ctx => !!ctx.user);

  return (
    <div>
      {isLoggedIn ? `Welcome ${userName}` : 'Please log in'}
    </div>
  );
}

Performance Issue Matrix (25 Scenarios)

Component Optimization Issues

  1. Excessive re-renders in DevTools → Missing React.memo → Add React.memo with custom comparison
  2. Child components re-render unnecessarily → Inline props/functions → Extract stable references with useCallback
  3. Slow typing in inputs → Expensive render calculations → Move to useMemo, use useTransition
  4. Context changes cause wide re-renders → Large single context → Split into focused contexts
  5. useState cascade re-renders → Poor state architecture → Use useReducer, state colocation

Bundle Optimization Issues

  1. Large initial bundle (>2MB) → No code splitting → Implement React.lazy route splitting
  2. Third-party libraries bloating bundle → Full library imports → Use specific imports, lighter alternatives
  3. Slow page load with unused code → Poor tree-shaking → Fix imports, configure webpack sideEffects
  4. Heavy CSS-in-JS performance → Runtime CSS generation → Extract static styles, use CSS variables

Memory Management Issues

  1. Memory usage grows over time → Missing cleanup → Add useEffect cleanup functions
  2. Browser unresponsive with large lists → Too many DOM elements → Implement react-window virtualization
  3. Memory leaks in development → Timers not cleared → Use AbortController, proper cleanup

Large Data Handling Issues

  1. Janky scroll performance → Large list rendering → Implement FixedSizeList virtualization
  2. Table with 1000+ rows slow → DOM manipulation overhead → Add virtual scrolling with pagination
  3. Search/filter causes UI freeze → Synchronous filtering → Use debounced useTransition filtering

Core Web Vitals Issues

  1. Poor Lighthouse score (<50) → Multiple optimizations needed → Image lazy loading, resource hints, bundle optimization
  2. High CLS (>0.1) → Content loading without dimensions → Set explicit dimensions, skeleton screens
  3. Slow FCP (>2s) → Blocking resources → Critical CSS inlining, resource preloading

Asset Optimization Issues

  1. Images loading slowly → Unoptimized images → Implement next/image, responsive sizes, modern formats
  2. Fonts causing layout shift → Missing font fallbacks → Add font-display: swap, system fallbacks
  3. Animation jank (not 60fps) → Layout-triggering animations → Use CSS transforms, GPU acceleration

Concurrent Features Issues

  1. UI unresponsive during updates → Blocking main thread → Use startTransition for heavy operations
  2. Search results update too eagerly → Every keystroke triggers work → Use useDeferredValue with debouncing
  3. Suspense boundaries poor UX → Improper boundary placement → Optimize boundary granularity, progressive enhancement

Advanced Performance Issues

  1. Production performance monitoring missing → No runtime insights → Implement Profiler components, Core Web Vitals tracking

Diagnostic Commands

Bundle Analysis

# Webpack Bundle Analyzer
npx webpack-bundle-analyzer build/static/js/*.js --no-open --report bundle-report.html

# Next.js Bundle Analysis
ANALYZE=true npm run build

# Vite Bundle Analysis
npm run build -- --mode analyze

# Manual bundle inspection
ls -lah build/static/js/ | sort -k5 -hr

Performance Profiling

# Lighthouse performance audit
npx lighthouse http://localhost:3000 --only-categories=performance --view

# Chrome DevTools performance
echo "Use Chrome DevTools > Performance tab to record and analyze runtime performance"

# React DevTools profiler
echo "Use React DevTools browser extension > Profiler tab for React-specific insights"

Memory Analysis

# Node.js memory debugging
node --inspect --max-old-space-size=4096 scripts/build.js

# Memory usage monitoring in browser
echo "Use performance.memory API and Chrome DevTools > Memory tab"

Validation Strategy

Performance Benchmarks

  • Component render time: <16ms per component for 60fps
  • Bundle size: Initial load <1MB, total <3MB
  • Memory usage: Stable over time, no growth >10MB/hour
  • Core Web Vitals: LCP <2.5s, FID <100ms, CLS <0.1

Testing Approach

# Performance regression testing
npm test -- --coverage --watchAll=false --testPathPattern=performance

# Bundle size tracking
npm run build && ls -lah build/static/js/*.js | awk '{sum += $5} END {print "Total bundle:", sum/1024/1024 "MB"}'

# Memory leak detection
echo "Run app for 30+ minutes with typical usage patterns, monitor memory in DevTools"

Production Monitoring

// Runtime performance monitoring
function AppWithMonitoring() {
  const onRender = (id, phase, actualDuration, baseDuration, startTime, commitTime) => {
    // Alert on slow renders
    if (actualDuration > 16) {
      analytics.track('slow_render', {
        componentId: id,
        phase,
        duration: actualDuration,
        timestamp: commitTime
      });
    }
  };

  return (
    <Profiler id="App" onRender={onRender}>
      <App />
    </Profiler>
  );
}

Resources

Official Documentation

Performance Tools

Best Practices

  • Profile first, optimize second - measure before and after changes
  • Focus on user-perceived performance, not just technical metrics
  • Use React 18 concurrent features for better user experience
  • Monitor performance in production, not just development

Code Review Checklist

When reviewing React performance code, focus on:

Component Optimization & Re-renders

  • Components use React.memo when appropriate to prevent unnecessary re-renders
  • useCallback is applied to event handlers passed to child components
  • useMemo is used for expensive calculations, not every computed value
  • Dependency arrays in hooks are optimized and stable
  • Inline objects and functions in JSX props are avoided
  • Component tree structure minimizes prop drilling and context usage

Bundle Size & Code Splitting

  • Route-based code splitting is implemented with React.lazy and Suspense
  • Heavy third-party libraries are loaded dynamically when needed
  • Bundle analysis shows reasonable chunk sizes (< 1MB initial)
  • Tree-shaking is working effectively (no unused exports in bundles)
  • Dynamic imports are used for conditional feature loading
  • Polyfills and vendor chunks are separated appropriately

Memory Management & Cleanup

  • useEffect hooks include proper cleanup functions for subscriptions
  • Event listeners are removed in cleanup functions
  • Timers and intervals are cleared when components unmount
  • Large objects are not held in closures unnecessarily
  • Memory usage remains stable during extended application use
  • Component instances are garbage collected properly

Data Handling & Virtualization

  • Large lists use virtualization (react-window or similar)
  • Data fetching includes pagination for large datasets
  • Infinite scrolling is implemented efficiently
  • Search and filter operations don't block the UI
  • Data transformations are memoized appropriately
  • API responses include only necessary data fields

Core Web Vitals & User Experience

  • Largest Contentful Paint (LCP) is under 2.5 seconds
  • First Input Delay (FID) is under 100 milliseconds
  • Cumulative Layout Shift (CLS) is under 0.1
  • Images are optimized and served in modern formats
  • Critical resources are preloaded appropriately
  • Loading states provide good user feedback

React 18 Concurrent Features

  • useTransition is used for non-urgent state updates
  • useDeferredValue handles expensive re-renders appropriately
  • Suspense boundaries are placed strategically
  • startTransition wraps heavy operations that can be interrupted
  • Concurrent rendering improves perceived performance
  • Error boundaries handle async component failures

Production Monitoring & Validation

  • Performance metrics are collected in production
  • Slow renders are detected and tracked
  • Bundle size is monitored and alerts on regressions
  • Real user monitoring captures actual performance data
  • Performance budgets are defined and enforced
  • Profiling data helps identify optimization opportunities

平台分布

Codex

38.4%
按下载量换算39

Claude

28.34%
按下载量换算29

Cursor

18.35%
按下载量换算19

Gemini CLI

9.22%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills