Skip to content

Latest commit

 

History

History
60 lines (34 loc) · 2.11 KB

performance-optimizations.md

File metadata and controls

60 lines (34 loc) · 2.11 KB

Performance Optimizations

Bundle Size Reduction

This document outlines the performance optimizations made to address large network payloads identified by Lighthouse.

Background

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)

Current Optimization Approach

Next.js handles bundling internally with its default configuration. The project no longer uses custom webpack configurations.

Component-Level Optimizations

  • 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

Benefits

These changes improve the application in several ways:

  1. Reduced Initial Load Time: By using Next.js's default optimization and loading components only when needed, the initial page load is faster.

  2. Lower Data Usage: Smaller bundles mean less data transferred, which is especially important for users on limited data plans or slower connections.

  3. Improved Performance Metrics: These optimizations directly address the Lighthouse performance issues related to large JavaScript payloads.

  4. Better Caching: Next.js's default chunking allows for more efficient browser caching.

Testing

To verify these improvements:

  1. Run Lighthouse performance tests to confirm the reduction in bundle sizes

  2. Test the application on slower connections (you can simulate this in Chrome DevTools)

Future Considerations

When adding new features or components:

  1. Always use dynamic imports for components that aren't needed immediately

  2. Import only the specific components you need from libraries, not entire packages

  3. Regularly analyze bundle sizes to catch any regressions

  4. Consider code splitting at the route level to further reduce initial load times