Back to list
JanSzewczyk

performance-optimization

by JanSzewczyk

This is Next.js Szumplate, an open source template for enterprise projects! It is packed with features that will help you create an efficient, maintainable and enjoyable application.

1🍴 0📅 Jan 18, 2026

SKILL.md


name: performance-optimization version: 1.0.0 lastUpdated: 2026-01-18 description: Performance optimization patterns for Next.js applications. Covers bundle analysis, React rendering optimization, database query optimization, Core Web Vitals, image optimization, and caching strategies. tags: [performance, bundle, react, optimization, core-web-vitals, caching] author: Szum Tech Team allowed-tools: Read, Write, Edit, Glob, Grep, Bash, WebFetch context: fork agent: general-purpose user-invocable: true examples:

  • How to reduce bundle size
  • Optimize React rendering
  • Fix slow database queries
  • Improve Core Web Vitals
  • Implement virtualized lists

Performance Optimization Skill

Performance optimization patterns for Next.js applications.

Reference Files:

Performance Philosophy

Principles:

  1. Measure first - Never optimize without metrics
  2. Target bottlenecks - Focus on the biggest impact areas
  3. User-centric - Prioritize perceived performance
  4. Iterative - Small, measurable improvements

Quick Reference

Bundle Size

# Analyze bundle
npm run analyze

# Targets
# - Total: < 200KB gzipped (first load)
# - Per-route: < 100KB gzipped

Quick Wins:

// Dynamic imports for heavy components
const Chart = dynamic(() => import("./Chart"), { ssr: false });

// Tree-shakeable imports
import { debounce } from "lodash-es";  // ✅
import _ from "lodash";                 // ❌

React Rendering

// With React Compiler - usually automatic optimization
// Manual memoization only for:

// 1. External library callbacks
const stableHandler = useCallback(() => {}, []);

// 2. Context values
const value = useMemo(() => ({ state, dispatch }), [state]);

// 3. Virtualized lists (50+ items)
import { useVirtualizer } from "@tanstack/react-virtual";

Database Queries

// Always use limits
const query = db.collection("items")
  .where("userId", "==", userId)
  .limit(20);

// Parallel fetching
const [users, posts] = await Promise.all([
  getUsers(),
  getPosts()
]);

Core Web Vitals

MetricTargetOptimization
LCP< 2.5spriority on hero image, preload fonts
INP< 200msstartTransition, defer non-critical JS
CLS< 0.1Fixed dimensions, skeleton loaders

Performance Targets

Bundle Size Targets

CategoryTarget (gzipped)
First Load JS< 100KB
Per-page JS< 50KB
Total app< 300KB
Single dependency< 30KB

Runtime Targets

MetricGoodNeeds Work
Time to Interactive< 3s> 5s
First Contentful Paint< 1.8s> 3s
Server Response< 200ms> 500ms
Database Query< 100ms> 500ms

Analysis Commands

# Bundle analysis
npm run analyze

# Build output
npm run build
# Check .next/static/chunks sizes

# Lighthouse (via Chrome DevTools)
# Performance tab → Lighthouse

# React Profiler
# React DevTools → Profiler tab

Decision Tree

Performance Issue?
    │
    ├─ Slow page load?
    │   ├─ Large bundle → Bundle analysis
    │   ├─ Slow API → Database optimization
    │   └─ Render blocking → Code splitting
    │
    ├─ Slow interactions?
    │   ├─ Long lists → Virtualization
    │   ├─ Heavy computation → Web Worker / useMemo
    │   └─ Frequent re-renders → React Profiler
    │
    └─ Layout shifts?
        ├─ Images → Set dimensions
        ├─ Fonts → Font preloading
        └─ Dynamic content → Skeleton loaders

Common Issues & Solutions

IssueDetectionSolution
Large bundle> 100KB first loadDynamic imports, tree shaking
Slow rendersReact Profiler > 16msMemoization, virtualization
N+1 queriesMultiple sequential DB callsBatch queries, denormalization
Layout shiftCLS > 0.1Fixed dimensions, skeletons
Unoptimized imagesLarge image filesnext/image, WebP, responsive
  • react-19-compiler - React Compiler optimization guidance
  • firebase-firestore - Database query patterns
  • structured-logging - Performance logging

Score

Total Score

75/100

Based on repository quality metrics

SKILL.md

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

+20
LICENSE

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

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

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

0/5
Issue管理

オープンIssueが50未満

+5
言語

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

+5
タグ

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

+5

Reviews

💬

Reviews coming soon