Performance Optimization

Optimize DotPassport widgets for the best user experience.

Bundle Size

The SDK is designed to be lightweight:

Package
Size (gzipped)

Full SDK

~8KB

Widget only

~6KB

API client only

~3KB


Tree Shaking

Import only what you need:

// ✅ Good - only imports what's needed
import { createWidget } from '@dotpassport/sdk';
import { DotPassportClient } from '@dotpassport/sdk';

// ❌ Avoid - imports everything
import * as DotPassport from '@dotpassport/sdk';

Lazy Loading

Dynamic Imports

Load widgets only when needed:

React Lazy Loading

Intersection Observer (Load on Scroll)


Caching Strategies

API Response Caching

Implement caching at the application level for best results:


Minimize Re-renders

React Optimization

Debounce Address Changes


Batch API Requests

Fetch multiple data points in parallel:


Preloading

Preload data before it's needed:


Resource Hints

Add preconnect hints for faster initial loads:


Multiple Widgets

Efficient Multi-Widget Setup

Virtual Scrolling for Many Widgets

For displaying many widgets, use virtualization:


Performance Monitoring

Measure Load Time

Web Vitals Integration


Best Practices Summary

Practice
Impact
Effort

Tree shaking

Medium

Low

Lazy loading

High

Medium

Response caching

High

Low

Parallel requests

Medium

Low

Debouncing

Medium

Low

Memoization

Medium

Medium

Preconnect hints

Low

Low


Last updated