Home
Chat
This website collects cookies to deliver better user experience
OK
React Code-Splitting
React Code-Splitting
Bundling
the process of following imported files and merging them into a single file ⇒ This bundle can be included on the webpage to load an entire app at once
Create React App, Next.js, Gatsby, or a similar tool having a bundle tool setup already
Code Splitting
App grows, bundle grows too ⇒ "splitting" bundle
Code splitting is a feature supported by a bundler which create multiple bundles that can be loaded dynamically at runtime
"lazy-load": just things needed currently
Good for performance: reduce the amount of code needed during the initial load
import()
When Webpack comes across this syntax, it automatically code-split your app if you are suing Create React App, also Next.js
React.lazy
lets you render a dynamic import as a regular component
Load the bundle when the lazy component is first rendered
The lazy component should be rendered in a
Suspense
component ⇒ fallback content while loading lazy component
Error boundaries
use it anywhere above your lazy components
Route-based code splitting
A good place to start is with routes
45
0
Categories:
React
Tags:
React
Performance
Webdev
Frontend
Related Posts
loading...
loading...
loading...
loading...
loading...
loading...
loading...
loading...
Post Comment
Show Comments
How to build powerful tables in React using the React Table package
Implementing tables using reactjs
Next.js Authentication with Netlify Identity
Websites To Learn Programming For Free
NodeJS vs Python
Best Website Speed and Performance Testing Tools Free
App Development Practices To Follow For Your Business In 2021
A first look at Qwik - the HTML first framework