An example of how to improve bundle size with Next.js
I work at a startup called Parallax, where we’re building a resource planning and project accounting app with Next.js. I recently noticed some of the pages would have a large “First Load JS” after running the
next build command in the terminal.
The approaches outlined in this article can be used with any third-party library to decrease the file size of your Next.js bundles. I will use the AnyChart library as an example — more specifically, the AnyChart-React library.
Below you will notice the
about pages are 795 kB in the “First Load JS” column. Before I added AnyChart to these pages, they were both 70.8 kB.
Next.js build output
According to the documentation, “The first load is colored green, yellow, or red. Aim for green for performant applications.” The docs also mention what the “Size” and “First Load JS” columns mean:
“Size — The number of assets downloaded when navigating to the page client-side. The size for each route only includes its dependencies.
First Load JS — The number of assets downloaded when visiting the page from the server. The amount of JS shared by all is shown as a separate metric.”
Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.
I show how to use React with Typescript: - How to define a component How to specify props using types and interfaces - How to define state - How to handle events
Start your new React project with Next.js and TypeScript. How to Set Up Next.js With TypeScript
Building a Web Application as a Front-End Developer using React JS and TypeScript! Learn how to use the “Thinking in React” method and apply it to your real web application. We will be using real live weather data to display in our application and make our components reusable and maintainable.