Code Splitting
Split flag components across routes to load only what’s needed per page.
Optimize your bundle size by choosing the right approach for your use case.
View detailed usage with code examples →
View detailed usage with code examples →
| Method | Bundle Size | Tree-shaking | Loading | Use Case |
|---|---|---|---|---|
| Named imports (3 flags) | ~2.8 KB | ✅ Excellent | Instant | Known flags at build time |
| Named imports (10 flags) | ~9.5 KB | ✅ Excellent | Instant | Common flags header |
| DynamicFlag | ~600 KB | ❌ None | Instant | CDN-restricted, all flags needed |
Code Splitting
Split flag components across routes to load only what’s needed per page.
Lazy Loading
Use your framework’s lazy loading (React lazy(), Vue defineAsyncComponent, Solid lazy())
to defer flags until they’re actually rendered.
Static Analysis
Run bundle analysis regularly to catch unexpected size increases.
Prefer Offline-first
Default to named imports. If you must support any runtime code synchronously, use DynamicFlag.
Use these tools to verify your bundle size:
# Webpack Bundle Analyzernpm install --save-dev webpack-bundle-analyzer
# Vite Bundle Analyzernpm install --save-dev rollup-plugin-visualizer
# Next.js Bundle Analyzernpm install --save-dev @next/bundle-analyzer