skills/ui-design/optimize/SKILL.md
Improve interface performance across loading speed, rendering, animations, images, and bundle size. Makes experiences faster and smoother.
npx skillsauth add mrlyk/skills optimizeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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:
srcset, picture element)<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:
// Lazy load heavy component
const HeavyChart = lazy(() => import('./HeavyChart'));
Optimize CSS:
Optimize Fonts:
font-display: swap or optional@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:
aspect-ratio CSS property/* 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.
development
把一段需求 / 一段思考 / 一段会议纪要写成单页 HTML 格式的「技术方案 / Design Doc」(工程视角的"怎么做",含背景、目标、技术方案、风险、影响范围、产研计划等模块;不是产品 PRD 的"做什么"),或者增量更新一份已有技术方案。新建场景:当用户说「写一份技术方案」「写个 design doc」「整理成 HTML 技术文档」「评审用的方案文档」「create tech spec」时使用。更新场景:当用户指向某份已有技术方案 HTML、说「评审完根据反馈调一下」「在风险章节加一条」「方案 A 改成 B」「补充某个章节」时也使用本 skill —— 走「最小化改动 + 保持文档稳定身份」的更新工作流而不是重写。
tools
Safe disk space analysis and cleanup workflow for local machines. Use when asked to analyze full disks, identify large cache/log/temp/build artifacts, produce a cleanup report, run or simulate dry-runs, wait for user approval, and then clean only confirmed redundant files without affecting software functionality, user data, databases, models, projects, or developer toolchains. Also use for creating reusable disk cleanup SOPs or post-cleanup reports.
tools
Improve typography by fixing font choices, hierarchy, sizing, weight consistency, and readability. Makes text feel intentional and polished.
documentation
One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.