by Sai gowtham

How to analyze the bundle size in React App

In this tutorial, we are going to learn about how to analyze the create react app bundle size using source-map-explorer.

Analyzing the bundle size

  1. First, we need to install a package called source-map-explorer in create react app using npm.
npm i source-map-explorer

Source map explorer helps us to analyze the JavaScript bundles using source maps.

  1. Now, open your package.json file and add the following line to scripts object.
"analyze": "source-map-explorer 'build/static/js/*.js'",
  1. Analyze the bundle size by running the following commands.
npm run build
npm run analyze

npm run build is used to build your react app code to production.

npm run analyze is used to analyze the code.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
26,545 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
221,520 students enrolled
44 hours of video content
View Course
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
114,575 students enrolled
21 hours of video content
View Course