jamiebuilds /react-loadable

:hourglass_flowing_sand: A higher order component for loading components with promises.

★ 16,494⑂ 757👁 141⑃ 240● 0▤ 0
JavaScriptMITCreated 2017-03-09
+0
日增长
16,494
stars
757
forks
141
watchers
240
prs
0
issues
0
releases

README

!React Loadable

 A higher order component for loading components with dynamic imports.

 Install

sh
yarn add react-loadable


 Example

js
import Loadable from 'react-loadable';
import Loading from './my-loading-component';

const LoadableComponent = Loadable({
  loader: () = import('./my-component'),
  loading: Loading,
});

export default class App extends React.Component {
  render() {
    return ;
  }
}


 Happy Customers:

- "I'm obsessed with this right now: CRA with React Router v4 and react-loadable. Free code splitting, this is so easy."
- "Oh hey - using loadable component I knocked 13K off my initial load. Easy win!"
- "Had a look and its awesome. shaved like 50kb off our main bundle."
- "I've got that server-side rendering + code splitting + PWA ServiceWorker caching setup done 😎 (thanks to react-loadable). Now our frontend is super fast."
- "Using react-loadable went from 221.28 KB → 115.76 KB @ main bundle. Fucking awesome and very simple API."
- "We've reduced our entry chunk by a lot & reduced initial load time by ~50%!"
- "React-loadable is killer! We've decreased our load size by over 50kb with only 2 files! Can't wait to see how much lower it will go."

 Users

- AdHawk / Flooring Stores
- Akutbolig.dk
- Analog.Cafe
- Ambrosus
- Appbase.io
- Atlassian
- BBC News
- Blytzpay
- ClearTax
- Cloudflare
- Chibaki
- Compass
- Curio
- Delivery.com
- Doctor.com
- Dollar Shave Club
- Dresez
- Edcast
- Evidation Health
- Flexport
- Flyhomes
- Gogo
- Gofore
- Graana
- Localie
- MediaTek MCS-Lite
- NiYO Solutions Inc.
- Officepulse
- PageSpeed Green
- Perx
- Plottu
- reformma
- Render
- Shift
- Snipit
- Spectrum.chat
- Superblocks
- Sprint Boards
- Talentpair
- Tinder
- Unsplash
- Wave
- WUZZUF
- Wxb

 _If your company or project is using React Loadable, please open a PR and add
 yourself to this list (in alphabetical order please)_

 Also See:

- react-loadable-visibility - Building on top of and keeping the same API as react-loadable, this library enables you to load content that is visible on the screen.

- react-loadable-ssr-addon - Server Side Render add-on for react-loadable. Discover & load automatically dynamically all files dependencies, e.g. splitted chunks, css, etc.


  
  
  
  
  
  Guide


So you've got your React app, you're bundling it with Webpack, and things are
going smooth. But then one day you notice your app's bundle is getting so big
that it's slowing things down.

It's time to start code-splitting your app!

!A single giant bundle vs multiple smaller bundles

Code-splitting is the process of taking one large bundle containing your entire
app, and splitting them up into multiple smaller bundles which contain separate
parts of your app.

This might seem difficult to do, but tools like Webpack have this built in, and
React Loadable is designed to make it super simple.

 Route-based splitting vs. Component-based splitting

A common piece of advice you will see is to break your app into separate routes
and load each one

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON