twobin / react-lazyload

Lazy load your component, image or anything matters the performance.
MIT License
5.85k stars 487 forks source link

Comparison between react-lazyload and React.Suspense + React.lazy API? #336

Open Monichre opened 3 years ago

Monichre commented 3 years ago

What are the differences between the inherent React Suspense API and this package? Why might/not this package be preferable?

devsdevsdevs commented 3 years ago

The wording is indeed very confusing.

This library allows you to improve performance in your application by not rendering components that aren't visible on the screen. This is similar in a way to virtual rendering libraries such as react virtualized and react-window. React Suspense, from my understanding currently only supports lazy-loading components, which means that components are dynamically imported when needed, which speeds up application load times by splitting up your application code. When your application goes to render a React Suspense lazy-loaded component, it performs an AJAX request to retrieve a JavaScript file containing the code for the component.