DEV Community

Discussion on: How to use React Suspense for Code-Splitting?

Collapse
 
sergiodxa profile image
Sergio Daniel Xalambrí • Edited

Start lazy loading at the router level, then only lazy load big components. Remember every lazy loaded component will need a new request to the server, lazy loading everything could make your app slower, you need to find the right spot for your app.

Collapse
 
marinovicmarko profile image
Marko Marinovic

I agree with Sergio. You should find the best use case for your app. Starting at the router level is perfect. I used this approach for my website because blog post content is in a form of .md files and it would be bad bundle it all together. It kinda mimics the behavior you would get by storing blog content in database and retrieving it on demand.

Collapse
 
asp2809 profile image
Anshu S Panda

Thanks for the reply. Now it's clear to me how and where to do the lazy loading.