<< All versions
Skill v1.0.0
LLM-judged scan90/100cap-go/capgo-skills/capacitor-performance
──Details
PublishedSeptember 29, 2026 at 02:57 PM
Content Hashsha256:57f39a2f90312acd...
Git SHAc0afb73c859a
──Files
Files (1 file, 3.3 KB)
SKILL.md3.3 KBactive
SKILL.md · 175 lines · 3.3 KB
version: "1.0.0" name: capacitor-performance description: Performance optimization guide for Capacitor apps covering bundle size, rendering, memory, native bridge, and profiling. Use this skill when users need to optimize their app performance.
Performance Optimization for Capacitor
Make your Capacitor apps fast and responsive.
When to Use This Skill
- User has slow app
- User wants to optimize
- User has memory issues
- User needs profiling
- User has janky animations
Quick Wins
1. Lazy Load Plugins
typescript
// BAD - All plugins loaded at startupimport { Camera } from '@capacitor/camera';import { Filesystem } from '@capacitor/filesystem';import { Geolocation } from '@capacitor/geolocation';// GOOD - Load when neededasync function takePhoto() {const { Camera } = await import('@capacitor/camera');return Camera.getPhoto({ quality: 90 });}
2. Reduce Bundle Size
bash
# Analyze bundlenpx vite-bundle-visualizer# Tree-shake importsimport { specific } from 'large-library'; // Goodimport * as everything from 'large-library'; // Bad
3. Optimize Images
typescript
// Use appropriate qualityconst photo = await Camera.getPhoto({quality: 80, // Not 100width: 1024, // Limit sizeresultType: CameraResultType.Uri, // Not Base64});// Lazy load images<img loading="lazy" src={url} />
4. Minimize Bridge Calls
typescript
// BAD - Multiple bridge callsfor (const item of items) {await Storage.set({ key: item.id, value: item.data });}// GOOD - Single call with batchawait Storage.set({key: 'items',value: JSON.stringify(items),});
Rendering Performance
Use CSS Transforms
css
/* GPU accelerated */.animated {transform: translateX(100px);will-change: transform;}/* Avoid - triggers layout */.animated {left: 100px;}
Virtual Scrolling
typescript
// Use virtual list for long listsimport { VirtualScroller } from 'your-framework';<VirtualScrolleritems={items}itemHeight={60}renderItem={(item) => <ListItem item={item} />}/>
Debounce Events
typescript
import { debounce } from 'lodash-es';const handleScroll = debounce((e) => {// Handle scroll}, 16); // ~60fps
Memory Management
Cleanup Listeners
typescript
import { App } from '@capacitor/app';// Store listener handleconst handle = await App.addListener('appStateChange', callback);// Cleanup on unmountonUnmount(() => {handle.remove();});
Avoid Memory Leaks
typescript
// Clear large data when donelet largeData = await fetchLargeData();processData(largeData);largeData = null; // Allow GC
Profiling
Chrome DevTools
- Connect via chrome://inspect
- Performance tab > Record
- Analyze flame chart
Xcode Instruments
- Product > Profile
- Choose Time Profiler
- Analyze hot paths
Android Profiler
- View > Tool Windows > Profiler
- Select CPU/Memory/Network
- Record and analyze
Metrics to Track
| Metric | Target | |
|---|---|---|
| First Paint | < 1s | |
| Time to Interactive | < 3s | |
| Frame Rate | 60fps | |
| Memory | Stable, no growth | |
| Bundle Size | < 500KB gzipped |
Resources
- Chrome DevTools: https://developer.chrome.com/docs/devtools
- Xcode Instruments: https://developer.apple.com/instruments