optimize by pbakaus/impeccable
npx skills add https://github.com/pbakaus/impeccable --skill optimize识别并修复性能问题,打造更快、更流畅的用户体验。
了解当前性能并识别问题:
衡量当前状态:
识别瓶颈:
关键:优化前后都要测量。过早的优化是浪费时间。优化真正重要的部分。
制定系统性改进计划:
优化图片:
srcset、picture 元素)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
<img
src="hero.webp"
srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"
loading="lazy"
alt="Hero image"
/>
减少 JavaScript 包大小:
// Lazy load heavy component
const HeavyChart = lazy(() => import('./HeavyChart'));
优化 CSS:
优化字体:
font-display: swap 或 optional@font-face {
font-family: 'CustomFont';
src: url('/fonts/custom.woff2') format('woff2');
font-display: swap; /* 立即显示回退字体 */
unicode-range: U+0020-007F; /* 仅基本拉丁字符 */
}
优化加载策略:
避免布局抖动:
// ❌ 差:交替进行读取和写入(导致重排)
elements.forEach(el => {
const height = el.offsetHeight; // 读取(强制布局)
el.style.height = height * 2; // 写入
});
// ✅ 好:批量读取,然后批量写入
const heights = elements.map(el => el.offsetHeight); // 全部读取
elements.forEach((el, i) => {
el.style.height = heights[i] * 2; // 全部写入
});
优化渲染:
contain 属性content-visibility: auto减少绘制与合成:
transform 和 opacity(GPU 加速)will-change 处理已知的昂贵操作GPU 加速:
/* ✅ GPU 加速(快) */
.animated {
transform: translateX(100px);
opacity: 0.5;
}
/* ❌ CPU 限制(慢) */
.animated {
left: 100px;
width: 300px;
}
流畅的 60fps:
requestAnimationFrameIntersection Observer:
// 高效检测元素何时进入视口
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
// 元素可见,懒加载或执行动画
}
});
});
React 特定:
memo()useMemo() 和 useCallback()框架无关:
减少请求:
优化 API:
针对慢速连接优化:
aspect-ratio CSS 属性/* 为图片预留空间 */
.image-container {
aspect-ratio: 16 / 9;
}
使用的工具:
关键指标:
重要:在真实设备和真实网络条件下进行测量。桌面版 Chrome 和快速连接并不具有代表性。
切勿:
will-change(创建新图层,占用内存)测试优化是否有效:
请记住:性能是一种特性。快速的体验让人感觉更灵敏、更精致、更专业。系统地进行优化,严格地进行测量,并优先考虑用户感知的性能。
每周安装量
28.3K
代码仓库
GitHub 星标数
13.4K
首次出现
2026年3月4日
安全审计
安装于
codex27.7K
opencode27.5K
github-copilot27.5K
gemini-cli27.5K
cursor27.5K
amp27.4K
Identify and fix performance issues to create faster, smoother user experiences.
Understand current performance and identify problems:
Measure current state :
Identify bottlenecks :
CRITICAL : Measure before and after. Premature optimization wastes time. Optimize what actually matters.
Create systematic improvement plan:
Optimize Images :
Use modern formats (WebP, AVIF)
Proper sizing (don't load 3000px image for 300px display)
Lazy loading for below-fold images
Responsive images (srcset, picture element)
Compress images (80-85% quality is usually imperceptible)
Use CDN for faster delivery
<img src="hero.webp" srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px" loading="lazy" alt="Hero image" />
Reduce JavaScript Bundle :
Code splitting (route-based, component-based)
Tree shaking (remove unused code)
Remove unused dependencies
Lazy load non-critical code
Use dynamic imports for large components
// Lazy load heavy component const HeavyChart = lazy(() => import('./HeavyChart'));
Optimize CSS :
Optimize Fonts :
Use font-display: swap or optional
Subset fonts (only characters you need)
Preload critical fonts
Use system fonts when appropriate
Limit font weights loaded
@font-face { font-family: 'CustomFont'; src: url('/fonts/custom.woff2') format('woff2'); font-display: swap; /* Show fallback immediately / unicode-range: U+0020-007F; / Basic Latin only */ }
Optimize Loading Strategy :
Avoid Layout Thrashing :
// ❌ Bad: Alternating reads and writes (causes reflows)
elements.forEach(el => {
const height = el.offsetHeight; // Read (forces layout)
el.style.height = height * 2; // Write
});
// ✅ Good: Batch reads, then batch writes
const heights = elements.map(el => el.offsetHeight); // All reads
elements.forEach((el, i) => {
el.style.height = heights[i] * 2; // All writes
});
Optimize Rendering :
contain property for independent regionscontent-visibility: auto for long listsReduce Paint & Composite:
transform and opacity for animations (GPU-accelerated)will-change sparingly for known expensive operationsGPU Acceleration :
/* ✅ GPU-accelerated (fast) */
.animated {
transform: translateX(100px);
opacity: 0.5;
}
/* ❌ CPU-bound (slow) */
.animated {
left: 100px;
width: 300px;
}
Smooth 60fps :
requestAnimationFrame for JS animationsIntersection Observer :
// Efficiently detect when elements enter viewport
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
// Element is visible, lazy load or animate
}
});
});
React-specific :
memo() for expensive componentsuseMemo() and useCallback() for expensive computationsFramework-agnostic :
Reduce Requests :
Optimize APIs :
Optimize for Slow Connections :
Set dimensions on images and videos
Don't inject content above existing content
Use aspect-ratio CSS property
Reserve space for ads/embeds
Avoid animations that cause layout shifts
/* Reserve space for image */ .image-container { aspect-ratio: 16 / 9; }
Tools to use :
Key metrics :
IMPORTANT : Measure on real devices with real network conditions. Desktop Chrome with fast connection isn't representative.
NEVER :
will-change everywhere (creates new layers, uses memory)Test that optimizations worked:
Remember: Performance is a feature. Fast experiences feel more responsive, more polished, more professional. Optimize systematically, measure ruthlessly, and prioritize user-perceived performance.
Weekly Installs
28.3K
Repository
GitHub Stars
13.4K
First Seen
Mar 4, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex27.7K
opencode27.5K
github-copilot27.5K
gemini-cli27.5K
cursor27.5K
amp27.4K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
AI智能体长期记忆系统 - 精英级架构,融合6种方法,永不丢失上下文
1,200 周安装
AI新闻播客制作技能:实时新闻转对话式播客脚本与音频生成
1,200 周安装
Word文档处理器:DOCX创建、编辑、分析与修订痕迹处理全指南 | 自动化办公解决方案
1,200 周安装
React Router 框架模式指南:全栈开发、文件路由、数据加载与渲染策略
1,200 周安装
Nano Banana AI 图像生成工具:使用 Gemini 3 Pro 生成与编辑高分辨率图像
1,200 周安装
SVG Logo Designer - AI 驱动的专业矢量标识设计工具,生成可缩放品牌标识
1,200 周安装