Next.js Discord

Discord Forum

Some questions regarding Dynamic loading.

Unanswered
Clown posted this in #help-forum
Open in Discord
So i was getting a warning:
..... preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly.

Hence i decided to start dynamically loading some client components.

The three components i am dynamically loading right now are
1) A profile icon which shows a popover(?) on clicking
(2) A part of the navbar which is client-side due to the use of usePathname(). This navbar may or may not be shown initially depending on whether you're on your mobile or on desktop.
3) A Chart.

I used to basically use useEffect() before this and i know that dynamic loading would defer the bundling of these components in the initial bundle.

What i would like to know is, is it better to use this approach in App Dir? What would be the difference between just using my previous approach instead of this one?

Sorry if this might sound like a "noob"y question.

1 Reply

Btw, the profile icon component may also not be shown initially due to
a) It has to get the userSession from Auth0
b) It is part of the responsive design so it also may not be shown depending on which device you are using.