Best practices for optimizing performance in Create React App projects #17174
Replies: 1 comment
-
|
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. |
Beta Was this translation helpful? Give feedback.
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 🙏
Beta Was this translation helpful? Give feedback.
All reactions