Skip to main content

Performance Optimization

This guide covers performance optimization strategies for the Privacy Boost TypeScript SDK.

WASM Loading

Lazy Loading

The WASM module is large. Load it only when needed:

Preloading

For routes that will need the SDK, preload in the background:

Code Splitting

Use route-based code splitting:

Balance Caching

Local Cache

The SDK caches balances automatically. Control cache behavior:

Smart Refresh

Only refresh when needed:

Batch Operations

Sync all balances at once instead of individually:

Network Optimization

Request Debouncing

Request Deduplication

Parallel Requests

Memory Management

Cleanup Subscriptions

Clear Unused Data

Limit History Size

Bundle Size

Tree Shaking

Import only what you need:

Analyze Bundle

Monitoring Performance

Track Operation Duration

React DevTools Profiler

Use React DevTools Profiler to identify slow renders.

Best Practices Summary

  1. Lazy load WASM - Don’t block initial page load
  2. Use cache wisely - Balance freshness vs performance
  3. Select specific state - Avoid unnecessary re-renders
  4. Batch operations - Reduce network requests
  5. Memoize calculations - Avoid redundant work
  6. Clean up subscriptions - Prevent memory leaks
  7. Monitor performance - Track slow operations

Next Steps