The optimize skill identifies and fixes performance issues to create faster, smoother user experiences. It addresses loading speed, rendering performance, animations, bundle size, and network efficiency.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pbakaus/impeccable/llms.txt
Use this file to discover all available pages before exploring further.
When to Use
Use the optimize skill when you need to:- Improve page load times and Core Web Vitals scores
- Reduce JavaScript bundle size
- Fix slow animations or janky interactions
- Optimize images and assets
- Reduce layout thrashing and reflows
- Improve mobile performance
- Make the interface feel faster and more responsive
Parameters
The specific feature or area to optimize. If not specified, optimizes the entire interface.
Important Principle
Workflow
The optimize skill follows a systematic approach:Assess Performance Issues
Understand current performance and identify problems:Measure current state:
- Core Web Vitals: LCP, FID/INP, CLS scores
- Load time: Time to interactive, first contentful paint
- Bundle size: JavaScript, CSS, image sizes
- Runtime performance: Frame rate, memory usage, CPU usage
- Network: Request count, payload sizes, waterfall
- What’s slow? (Initial load? Interactions? Animations?)
- What’s causing it? (Large images? Expensive JavaScript? Layout thrashing?)
- How bad is it? (Perceivable? Annoying? Blocking?)
- Who’s affected? (All users? Mobile only? Slow connections?)
Apply Optimization Strategy
Systematically improve performance across all relevant dimensions (see below).
Optimization Strategies
Loading Performance
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,pictureelement) - Compress images (80-85% quality is usually imperceptible)
- Use CDN for faster delivery
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
Optimize CSS
- Remove unused CSS
- Critical CSS inline, rest async
- Minimize CSS files
- Use CSS containment for independent regions
Optimize Fonts
- Use
font-display: swaporoptional - Subset fonts (only characters you need)
- Preload critical fonts
- Use system fonts when appropriate
- Limit font weights loaded
Rendering Performance
Avoid Layout Thrashing
Optimize Rendering
- Use CSS
containproperty for independent regions - Minimize DOM depth (flatter is faster)
- Reduce DOM size (fewer elements)
- Use
content-visibility: autofor long lists - Virtual scrolling for very long lists (react-window, react-virtualized)
Reduce Paint & Composite
- Use
transformandopacityfor animations (GPU-accelerated) - Avoid animating layout properties (width, height, top, left)
- Use
will-changesparingly for known expensive operations - Minimize paint areas (smaller is faster)
Animation Performance
GPU Acceleration
Smooth 60fps
- Target 16ms per frame (60fps)
- Use
requestAnimationFramefor JS animations - Debounce/throttle scroll handlers
- Use CSS animations when possible
- Avoid long-running JavaScript during animations
Intersection Observer
React/Framework Optimization
React-specific
- Use
memo()for expensive components useMemo()anduseCallback()for expensive computations- Virtualize long lists
- Code split routes
- Avoid inline function creation in render
- Use React DevTools Profiler
Framework-agnostic
- Minimize re-renders
- Debounce expensive operations
- Memoize computed values
- Lazy load routes and components
Network Optimization
Reduce Requests
- Combine small files
- Use SVG sprites for icons
- Inline small critical assets
- Remove unused third-party scripts
Optimize APIs
- Use pagination (don’t load everything)
- GraphQL to request only needed fields
- Response compression (gzip, brotli)
- HTTP caching headers
- CDN for static assets
Optimize for Slow Connections
- Adaptive loading based on connection (navigator.connection)
- Optimistic UI updates
- Request prioritization
- Progressive enhancement
Core Web Vitals Optimization
Largest Contentful Paint (LCP < 2.5s)
- Optimize hero images
- Inline critical CSS
- Preload key resources
- Use CDN
- Server-side rendering
First Input Delay (FID < 100ms) / INP (< 200ms)
- Break up long tasks
- Defer non-critical JavaScript
- Use web workers for heavy computation
- Reduce JavaScript execution time
Cumulative Layout Shift (CLS < 0.1)
- Set dimensions on images and videos
- Don’t inject content above existing content
- Use
aspect-ratioCSS property - Reserve space for ads/embeds
- Avoid animations that cause layout shifts
Performance Monitoring
Tools to use:- Chrome DevTools (Lighthouse, Performance panel)
- WebPageTest
- Core Web Vitals (Chrome UX Report)
- Bundle analyzers (webpack-bundle-analyzer)
- Performance monitoring (Sentry, DataDog, New Relic)
- LCP, FID/INP, CLS (Core Web Vitals)
- Time to Interactive (TTI)
- First Contentful Paint (FCP)
- Total Blocking Time (TBT)
- Bundle size
- Request count
Usage Example
Best Practices
DO:- Measure before optimizing
- Test on real devices (especially low-end Android)
- Test with throttled connections (3G)
- Optimize the biggest bottleneck first
- Track real user monitoring data
- Optimize without measuring (premature optimization)
- Sacrifice accessibility for performance
- Break functionality while optimizing
- Use
will-changeeverywhere (creates new layers, uses memory) - Lazy load above-fold content
- Optimize micro-optimizations while ignoring major issues
- Forget about mobile performance (often slower devices, slower connections)
