Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use loadable-components in NextJS app?

I'm trying to improve my site performance and the Google Chrome Lighthouse tells me to use loadable-components for ssr in order to "remove unused javascript".

What I found in the doc is it seems to be a library with useful functions for my case, eg: component splitting/ loading library.

My question is:

  1. Does @loadable/component is really that good?
  2. If it is good, should I use it for any component/library import?

Thank you!

like image 643
agentp Avatar asked Mar 06 '26 02:03

agentp


1 Answers

By default, Next.js splits your JavaScript into separate chunks for each route. So when users load your application, Next.js only sends the code needed for the initial route.

You can further optimize the loading process with code splitting on the component level using inbuilt next/dynamic

Refer code splitting with dynamic imports for more details.

like image 157
Shyam Avatar answered Mar 07 '26 17:03

Shyam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!