Repository navigation
Best practices for optimizing performance in Create React App projects #17174
Replies: 2 comments
|
here are some practical tips for cra performance: build time improvements:
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"]
}
bundle size reduction:
npm install -D source-map-explorer
npx source-map-explorer build/static/js/*.js
const HeavyComponent = React.lazy(() => import("./HeavyComponent"));
// bad
import _ from "lodash";
// good
import debounce from "lodash/debounce";
production performance:
about ejecting: i would avoid ejecting. instead use craco or react-app-rewired to customize webpack without ejecting. this keeps you updatable: npm install -D @craco/cracothen customize in craco.config.js. if cra is too limiting, consider migrating to vite or next.js which are faster and more flexible. |
|
Hi! One additional recommendation I would make is to measure performance before changing the build configuration. For a large CRA application, I would focus on these areas:
I would recommend measuring the existing application first, applying targeted optimizations, and then comparing production build results. Useful references: |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone 👋
I’m currently working on a fairly large project using Create React App, and I’ve started noticing performance issues both during build time and when running in production.
I’d love to hear from the community:
Any tips, experiences, or resources would be greatly appreciated 🙏
All reactions