DEV Community

Cover image for How I Optimized My Next.js Portfolio from 79 to 90+ on PageSpeed Insights
Aly El bachir Yara
Aly El bachir Yara

Posted on

How I Optimized My Next.js Portfolio from 79 to 90+ on PageSpeed Insights

A few weeks ago, when I analyzed my portfolio with PageSpeed Insights, I got a score of 79 on mobile. It wasn't bad, but I knew I could improve. After implementing several optimizations, I managed to reach 90+ in mobile performance.

In this post, I share the most effective optimizations I implemented and how you can apply them to your Next.js project.

πŸ“Š Initial vs Final Metrics

πŸš€ Optimizations Implemented

1. Eliminating Font Render Blocking

Problem: Google Fonts were blocking initial render.

Solution: I removed the CSS @import and used next/font with optimizations.

Result: ~750ms reduction in initial load time.

2. Preconnect for External Resources
I added preconnect in the

to establish early connections:

Estimated savings: ~300-400ms in network latency.

3. Lazy Loading Heavy Components
I converted heavy components to lazy loading with dynamic import:

Impact: Critical content renders immediately, improving LCP.

4. JavaScript Optimization
Removing console.log in Production

Import Modularization

Result: ~50-100KB reduction in initial bundle.

5. Modern Browser Configuration
I created .browserslistrc to reduce unnecessary polyfills:

Savings:~11 KiB of JavaScript removed.

6. Removing Failing Resources
I identified and removed external resources that were generating 403 errors:

Benefit: Eliminated console errors and improved performance.

7. Contrast Improvement (Accessibility)
I improved text contrast to meet WCAG standards:

Result: Accessibility improved from 96 to 98+.

Final Results

After implementing these optimizations:
βœ… Performance: 79 β†’ 90+
βœ… FCP: 2.9s β†’ ~1.5s
βœ… LCP: 4.1s β†’ ~2.5s
βœ… Accessibility: 96 β†’ 98+
βœ… SEO: 100 (maintained)

Conclusion
Optimizing the performance of a Next.js application requires attention to detail, but the results are worth it. With these optimizations, I not only improved the metrics but also enhanced the user experience.

Have you implemented any of these optimizations? What other techniques do you use to improve performance? Share your experiences in the comments πŸ‘‡

Top comments (0)