cap-go/capgo-skills

capacitor-performance

Performance optimization guide for Capacitor apps covering bundle size, rendering, memory, native bridge, and profiling.

Ver código-fonte

Como usar

  1. Copie o comando e verifique o pacote antes de instalar no seu ambiente de agente.
  2. Consulte no original as ferramentas, credenciais e ambientes necessários.
  3. Descreva os dados de entrada e a entrega esperada; confira a saída com as fontes.
npx skills add https://github.com/cap-go/capgo-skills --skill capacitor-performance

Antes de começar

  • A instalação não inclui assinatura de modelo, franquia API ou acesso aos seus arquivos.
  • Estrelas e instalações indicam atividade, não um teste independente de qualidade ou segurança.
Documento original do Skill

Renderizado do repositório de origem, preservando títulos, exemplos, código, tabelas, links e imagens.

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 startup
import { Camera } from '@capacitor/camera';
import { Filesystem } from '@capacitor/filesystem';
import { Geolocation } from '@capacitor/geolocation';

// GOOD - Load when needed
async function takePhoto() {
  const { Camera } = await import('@capacitor/camera');
  return Camera.getPhoto({ quality: 90 });
}

2. Reduce Bundle Size

bash
# Analyze bundle
npx vite-bundle-visualizer

# Tree-shake imports
import { specific } from 'large-library';  // Good
import * as everything from 'large-library'; // Bad

3. Optimize Images

typescript
// Use appropriate quality
const photo = await Camera.getPhoto({
  quality: 80,        // Not 100
  width: 1024,        // Limit size
  resultType: CameraResultType.Uri,  // Not Base64
});

// Lazy load images
<img loading="lazy" src={url} />

4. Minimize Bridge Calls

typescript
// BAD - Multiple bridge calls
for (const item of items) {
  await Storage.set({ key: item.id, value: item.data });
}

// GOOD - Single call with batch
await 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 lists
import { VirtualScroller } from 'your-framework';

<VirtualScroller
  items={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 handle
const handle = await App.addListener('appStateChange', callback);

// Cleanup on unmount
onUnmount(() => {
  handle.remove();
});

Avoid Memory Leaks

typescript
// Clear large data when done
let largeData = await fetchLargeData();
processData(largeData);
largeData = null; // Allow GC

Profiling

Chrome DevTools

  1. Connect via chrome://inspect
  2. Performance tab > Record
  3. Analyze flame chart

Xcode Instruments

  1. Product > Profile
  2. Choose Time Profiler
  3. Analyze hot paths

Android Profiler

  1. View > Tool Windows > Profiler
  2. Select CPU/Memory/Network
  3. Record and analyze

Metrics to Track

MetricTarget
First Paint< 1s
Time to Interactive< 3s
Frame Rate60fps
MemoryStable, no growth
Bundle Size< 500KB gzipped

Resources

  • Chrome DevTools: https://developer.chrome.com/docs/devtools
  • Xcode Instruments: https://developer.apple.com/instruments

Relacionados por tarefa

do mesmo repositório

Mais Skills

Todos os Skills
cap-go
Comunidade

debugging-capacitor

Diagnoses and fixes runtime bugs in Capacitor iOS/Android apps - white/blank screen on launch, startup crashes, "X" plugin is not implemented on ios/android, net::ERRCLEARTEXTNOTPERMITTED, App Transport Security blocks, CORS on capacitor://localhost, permission denials, live reload not connecting, and Capacitor 8.5+ UIScene regressions (appUrlOpen, universal links, pause/resume silent because AppDelegate callbacks stopped). Covers Safari Web Inspector, chrome://inspect, Xcode/LLDB, Android Studi

instalações
2
GitHub Stars
74
Atualizado
17 de out.
cap-go
Comunidade

capacitor-plugins

Pick, install, and wire up Capacitor plugins for native features (camera, filesystem, geolocation, biometrics, in-app purchases, social login, SQLite, calendar, contacts, health, BLE, NFC, etc.). Covers official @capacitor/ packages (Capacitor 8.5 stable, 9 alpha on next) plus the 145-package @capgo/ index, native permission keys (Info.plist, AndroidManifest, variables.gradle minSdk), npx cap sync / cap ls verification, and errors like '"Camera" plugin is not implemented on ios', 'unable to find

instalações
2
GitHub Stars
74
Atualizado
17 de out.
cap-go
Comunidade

capacitor-ios-security-hardening

Audits and progressively hardens Xcode security build settings for a Capacitor iOS app (ios/App/App.xcodeproj, scheme App) and native plugin code (Swift/ObjC/C, Package.swift, podspec). Covers xcodebuild -showBuildSettings -json, security compiler warnings, static analyzer checkers (xcodebuild analyze), Xcode Enhanced Security (ENABLEENHANCEDSECURITY, com.apple.security.hardened-process entitlements, pointer authentication / arm64e, memory tagging soft mode), what is safe for a WKWebView hybrid

instalações
1
GitHub Stars
74
Atualizado
17 de out.
cap-go
Comunidade

capacitor-splash-screen

Guide to configuring splash screens in Capacitor apps including asset generation, animation, and programmatic control. Use this skill when users need to customize their app launch experience.

instalações
1
GitHub Stars
72
Atualizado
13 de jul.