Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
189
rated 0 times [  191] [ 2]  / answers: 1 / hits: 27287  / 3 Years ago, sat, december 26, 2020, 12:00:00

I have a project on Next.js framework and the problem is that First Load JS shared by all pages is rather heavy.


I want to know what possible aspects I can take into consideration to reduce it and also know if I'm doing something wrongly.



my next js version : ^10.0.3



information relating to pages while building :
enter


More From » reactjs

 Answers
10

I would suggest installing @next/bundle-analyzer to get a better idea of what dependencies you're importing and which ones are contributing to that file size. This can help in identifying any unused or unnecessary libraries that could potentially be removed.


You can also look into using code splitting to reduce the bundle for the initial load of the application. This can be achieve by lazy loading code using dynamic import() and/or next/dynamic.


Furthermore, Next.js also mentions in their documentation other tools you can use to understand how much a dependency can add to your bundle.



(...) you can use the following tools to understand what is included inside each JavaScript bundle:



  • Import Cost – Display the size of the imported package inside VSCode.

  • Package Phobia – Find the cost of adding a new dev dependency to your project.

  • Bundle Phobia - Analyze how much a dependency can increase bundle sizes.

  • Webpack Bundle Analyzer – Visualize size of webpack output files with an interactive, zoomable treemap.

  • bundlejs - An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.


Next.js, Going to Production, Reducing JavaScript Size



[#50476] Saturday, December 5, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;