mcpField
F
frontend-perf

frontend-perf

github.com/fudesign2008Development645 installsUpdated today
Repository

About frontend-perf

frontend-perf is a reference skill for developers optimizing browser and Electron frontend performance. It organizes metrics, bottleneck patterns, version-specific guidance, and optimization priorities for use with perf-workflow.

Key features

  1. 01RAIL、Web Vitals 和 Electron 指标参考
  2. 02前端性能瓶颈模式
  3. 03React、Angular 和 Electron 版本建议
  4. 04优化事项优先级参考
  5. 05分析与验证标准

Use cases

  1. 01为前端性能建立量化基线
  2. 02定位重排、长任务或内存增长
  3. 03规划 React 或 Angular 优化
  4. 04核验 Electron 启动和 IPC 性能

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fudesign2008/open-skills --skill frontend-perf

After installing, type/frontend-perfin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

Frontend Performance Optimization Knowledge Base

Relationship with perf-workflow

This skill is the knowledge layer for perf-workflow, which is the process layer; the two are used together.

perf-workflow stageFrontend-specific content provided by this skill
Stage 1: Performance evidenceQuantitative baselines: RAIL / Web Vitals / Electron metric thresholds
Stage 2: Performance localizationFrontend bottleneck pattern table; render-pipeline localization rules
Stage 3: Performance hypothesisFrontend-specific root causes (reflow / long tasks / IPC / leaks)
Stage 4: Performance monitoringApplicable tools and instrumentation points
Stage 5: Performance optimizationOptimization priority reference (P0 → P1 → P2)
Stage 6: Performance verificationPass criteria (LCP/INP/CLS/startup time)

Quantitative Standards Quick Reference

RAIL Model (Google Chrome team, W3C recommended)
PhaseFull nameUser-perceived thresholdCore optimization direction
RResponseInteraction → feedback < 100msLightweight event handlers, never block the main thread
AAnimationSteady 60fps, per-frame < 16msOnly use transform/opacity, avoid reflow
IIdleSplit idle work into < 50ms chunksUse requestIdleCallback to schedule non-urgent tasks
LLoadFirst content < 2s, usable < 5sReduce the number and size of critical resources
Web Vitals: The Three Core Metrics (2024 edition)
MetricFull nameGoodNeeds improvementOptimization focus
LCPLargest Contentful Paint< 2.5s> 4sFirst-screen loading, critical rendering path
INPInteraction to Next Paint< 200ms> 500msMain-thread long tasks, interaction responsiveness
CLSCumulative Layout Shift< 0.1> 0.25Layout stability, reserved image dimensions
Electron Desktop Extended Metrics
MetricPass threshold (industry standard)Localization tool
Cold start timeWindows < 2s, macOS < 1.5sElectron DevTools / instrumentation timing
Warm start time< 500msInstrumentation timing
IPC round-trip time< 50ms per call (for frequent calls)IPC log instrumentation
Renderer process memoryNo sustained growth, stable baselineChrome DevTools Memory panel
Main-thread CPUNear 0 when idle, no long tasksChrome DevTools Performance panel

Frontend-Specific Bottleneck Patterns

Supplements the generic pattern table in perf-workflow Stage 3; below are common concrete forms seen in frontend code:

PatternConcrete frontend manifestationTypical trigger scenario (frontend)Localization tool
Reflow (Layout)Reading/writing geometric properties re-triggers the entire render pipelineChanging width/height/position; reading offsetWidth/scrollTop then writing to the DOMPerformance panel Layout marker
Repaint (Paint)Changing visual properties triggers a repaint, skipping LayoutChanging color/shadow/backgroundPerformance panel Paint marker
Main-thread long taskA single task > 50ms blocks the event loop, INP exceeds targetHeavy data processing/complex computation/synchronous IPC running on the main threadPerformance panel Long Task marker
Unnecessary re-renderComponent props/state unchanged but re-render is still triggeredUnstable props references; overly coarse global state granularity; excessive context updatesReact Profiler / Vue DevTools
IPC blockingElectron synchronous IPC or high-frequency IPC saturates the main threadsendSync calls; sending IPC at high frequency inside scroll/input handlersElectron logs + Performance panel
Continuous memory growthMemory not released, GC cannot reclaim it, eventually causing jank/crashEvent listeners not unbound; timers not cleared; large objects held by closuresMemory panel Heap Snapshot
Layout thrashingAlternating "read-write-read-write" of DOM properties, each write forces a synchronous layoutAlternately reading/modifying DOM geometry inside a loopPerformance panel with dense Layout markers
Underused React Concurrent featuresIn React 18+ projects, long computations still run on the synchronous path, blocking user input responseNot using useTransition / startTransition to mark low-priority updatesReact DevTools Profiler timeline
Excessive Angular Zone triggeringZone.js intercepts every async operation and triggers change detection across the whole treeNot using NgZone.runOutsideAngular() to isolate high-frequency eventsAngular DevTools Profiler

Key Optimization Features by Framework Version

During analysis/optimization, confirm the framework version first, then pick the matching strategy — strategies differ significantly between versions.

React Versions
VersionKey performance featureOptimization impact
16.xPureComponent / shouldComponentUpdate / class componentsManual control of re-renders, no Hooks
16.8+useMemo / useCallback / useRef / React.memoFunction components can do fine-grained memoization
18Concurrent Rendering / automatic batching / useTransition / useDeferredValuePriority scheduling; multiple setState calls auto-merge; long tasks can be marked low priority
19React Compiler (automatic memoization) / use()The compiler automatically handles reference stability; most cases no longer need hand-written memo
Angular Versions
VersionKey performance featureOptimization impact
9+Ivy compilerSmaller bundles, faster compilation, tree-shaking friendly
14+Standalone ComponentsReduces NgModule overhead, finer-grained lazy loading
16+Signals (signal() / computed() / effect())Fine-grained reactivity, can bypass Zone.js change detection
17+@defer blocks / @for ... trackBuilt-in deferred rendering; trackBy built into the template syntax
18+Zoneless change detection (experimental)Removes the Zone.js patch, fully eliminating Zone-triggered overhead
Electron Versions
VersionKey performance featureOptimization impact
12+remote module deprecated, contextIsolation on by defaultMust use contextBridge, eliminating remote's synchronous IPC overhead
20+sandbox: true on by defaultLighter renderer process initialization, requires adjusting the preload script
22+UtilityProcess APIThe proper home for CPU-intensive tasks, replacing child_process.fork
28+Native ESM support in the renderer processNative import() is usable, more thorough tree-shaking

Browser Rendering Pipeline Essentials

Render path: DOM → CSSOM → Style → Layout (reflow) → Paint (repaint) → Composite

Operation typeHighest-cost phase triggeredTypical CSS propertiesPerformance tier
Geometric changeLayout (reflow)width / height / top / marginSlowest
Visual changePaint (repaint)color / background / box-shadowMedium
Composite changeComposite onlytransform / opacityFastest

Core rule: animations and scrolling should only use transform / opacity; batch and minimize any other property changes.


Electron Multi-Process Essentials

Process typeCore responsibilityBlocking impactOptimization red line
Main processApp lifecycle, window management, system APIsAll windows freeze / become unresponsiveNo synchronous IO / CPU-intensive tasks / tight loops
Renderer processWindow UI rendering, JS execution, user interactionThe current window freezesSame rules as web frontend; no synchronous IPC
GPU process3D drawing, hardware acceleration, compositor layer renderingAnimation jank, screen tearingAvoid excessive hardware acceleration; prevent compositor layer explosion
Worker processCPU-intensive tasks, file IO, background computationDoes not affect the UI threadAll time-consuming tasks must run on this type of process/Worker

Core IPC rule: never use ipcRenderer.sendSync; throttle IPC in high-frequency events; use SharedArrayBuffer for zero-copy transfer of large data.


Optimization Priority Quick Reference

Prioritize the steps that consume the largest share of time — optimizing a step that accounts for < 10% by 100x still yields limited overall gain (Amdahl's law).

P0: Do first (high impact, low cost)
  • Split long tasks: break synchronous tasks > 50ms into chunks < 50ms, scheduled via requestIdleCallback
  • Virtual scrolling: mandatory for long lists (> 100 items), use react-window / vue-virtual-scroller
  • Avoid reflow: use only transform/opacity for animation; batch-read then batch-write the DOM
  • Async IPC: convert all Electron IPC to async; remove every sendSync
  • Web Worker: move large-data parsing/encryption/complex computation off the main thread
P1: Next (moderate cost, clear payoff)
  • Component memoization: React.memo / useMemo / useCallback to stabilize props and function references
  • State granularity: split overly coarse global state to reduce unnecessary re-render scope
  • Code splitting: route-level / component-level dynamic import to reduce first-screen JS size
  • Electron startup: keep the main-process entry as lean as possible; load non-first-screen modules asynchronously
P2: Optional (engineering payoff, longer horizon)
  • Caching strategy: long-term strong caching + hashed filenames for static assets; Service Worker offline caching
  • Bundle size reduction: tree-shaking; import large libraries on demand; use WebP/AVIF for images
  • Performance budget + CI/CD gate: bring LCP/INP/bundle size into the pipeline, block releases that exceed the budget

See reference.md for detailed implementation approaches.


Analysis Tools Quick Reference

ScenarioRecommended tool
Main-thread long tasksChrome DevTools → Performance panel → Long Tasks
Rendering bottlenecksChrome DevTools → Performance → Rendering panel
React re-rendersReact DevTools Profiler (flame graph + ranked chart)
React 18+ scheduling priorityReact DevTools Profiler → timeline view, check Concurrent priority markers
Angular change detectionAngular DevTools → Profiler (check change detection count and duration)
Angular SignalsAngular DevTools 17+ → Signal dependency graph visualization (experimental)
Memory leaksChrome DevTools → Memory → compare Heap Snapshots
Web VitalsLighthouse / Chrome DevTools → Performance Insights
Electron process overviewapp.getAppMetrics() to check CPU/memory per process; system resource monitor
Electron IPC timingCustom log instrumentation + Chrome DevTools Performance panel
Bundle size analysiswebpack-bundle-analyzer / vite-plugin-inspect

Comments

Markdown supported