Back to list
zzoohub

performance-patterns

by zzoohub

diet-diary & sharing app made with react-native

0🍴 0📅 Jan 23, 2026

SKILL.md


name: performance-patterns description: | Web performance patterns and Core Web Vitals optimization. Use when: optimizing load times, fixing CWV issues, code splitting. Do not use for: SEO (use seo skill), general React patterns (use nextjs skill). Workflow: Use after core features are built.

Performance Patterns

For latest framework APIs, use context7.


Core Web Vitals Targets

MetricTargetMeasures
LCP (Largest Contentful Paint)< 2.5sLoading
INP (Interaction to Next Paint)< 200msResponsiveness
CLS (Cumulative Layout Shift)< 0.1Visual stability

Quick Wins

1. Lighter Alternatives

HeavyLightSavings
moment.jsdate-fns, dayjs~300KB → ~2KB
lodash (full)lodash-es (tree-shake)~70KB → ~5KB
axiosfetch (native)~13KB → 0

Rule: Import only what you need.

// ❌ Imports entire lodash
import _ from 'lodash';

// ✅ Import only what you need
import debounce from 'lodash/debounce';

2. Code Splitting

Rule: Split large components that aren't needed on initial load.

  • Route-based: Automatic in Next.js App Router, Expo Router
  • Component-based: Use dynamic imports for heavy components
  • Library-based: Import heavy libraries only when needed

For implementation, use context7 MCP or see:

3. Dynamic Import for Libraries

Rule: Load heavy libraries only when user triggers the action.

async function exportToPDF() {
  const { jsPDF } = await import('jspdf');
  // use jsPDF...
}

Layout Stability (CLS)

Rule: Always reserve space for dynamic content.

ElementSolution
ImagesSet width/height or aspect-ratio
Dynamic contentSet minHeight, use skeleton
FontsUse font-display: swap
Ads/embedsReserve container space

Data Fetching

Rule: Cache aggressively, prefetch on intent.

PatternWhen
staleTimeData that doesn't change often
Prefetch on hoverLinks user is likely to click
Background refetchKeep data fresh without blocking

Expensive Operations

PatternUse for
DebounceSearch inputs, resize handlers
ThrottleScroll handlers, frequent events
VirtualizationLists > 100 items
Web WorkersHeavy computations

Quick Checklist

Loading (LCP)

  • Critical CSS inlined
  • Images optimized (WebP/AVIF, proper sizing)
  • Fonts preloaded
  • Heavy libraries dynamically imported

Responsiveness (INP)

  • Click handlers are fast
  • Heavy work deferred
  • Expensive operations debounced

Stability (CLS)

  • Images have width/height
  • Dynamic content has reserved space
  • Fonts use font-display: swap
  • No layout-shifting ads/embeds

Bundle

  • No full lodash/moment imports
  • Large components code-split
  • Bundle analyzed for bloat

Score

Total Score

40/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon