This document outlines the performance optimizations made to address large network payloads identified by Lighthouse.
Lighthouse reported large JavaScript bundles that were impacting performance:
Large network payloads cost users real money and are highly correlated with long load times.
The largest bundles included:
- main.js (1,545.5 KiB)
- _pages-dir-browser_components_ui_LearningTable_js.js (1,044.5 KiB)
- pages/index.js (916.5 KiB)
- pages/_app.js (631.3 KiB)
Next.js handles bundling internally with its default configuration. The project no longer uses custom webpack configurations.
- Replaced broad imports from Material Tailwind with specific component imports
- Example: Changed from
import { Button, Dialog, ... } from "@material-tailwind/react"
to individual imports from specific paths
These changes improve the application in several ways:
-
Reduced Initial Load Time: By using Next.js's default optimization and loading components only when needed, the initial page load is faster.
-
Lower Data Usage: Smaller bundles mean less data transferred, which is especially important for users on limited data plans or slower connections.
-
Improved Performance Metrics: These optimizations directly address the Lighthouse performance issues related to large JavaScript payloads.
-
Better Caching: Next.js's default chunking allows for more efficient browser caching.
To verify these improvements:
-
Run Lighthouse performance tests to confirm the reduction in bundle sizes
-
Test the application on slower connections (you can simulate this in Chrome DevTools)
When adding new features or components:
-
Always use dynamic imports for components that aren't needed immediately
-
Import only the specific components you need from libraries, not entire packages
-
Regularly analyze bundle sizes to catch any regressions
-
Consider code splitting at the route level to further reduce initial load times