Bundle Size and Typing Improvements

Learn about the optimization of JavaScript bundle sizes in front-end apps using RxJS 7.

Exploring the bundle size improvements

Every front-end application needs a number of JavaScript files to run. These files are either the ones we’ve written ourselves or the external dependencies used to build the application, such as Moment.js, Lodash, or RxJS. A bundle is an output of a process that merges all these files into a few (if not single) files in the most optimized way possible.

One of the major approaches commonly used to improve front-end performance is reducing the JavaScript bundle size. The smaller the size of the JavaScript bundle, the faster a page can load the first time and be available to users.

Bundle size optimization in RxJS 7

The RxJS core team worked on reducing the bundle size of the library in version 7; they did a lot of refactoring to optimize the code and, consequently, the bundle size.

To get a better idea, let’s measure the bundle sizes of two front-end applications using RxJS 6 and RxJS 7 and compare the size of the RxJS library in both applications. There are a lot of tools that can help us measure and analyze the bundles. The one that we’re going to use is the source map explorer. The source map explorer enables us to analyze bundles that have a source map by offering a visual representation. In fact, it shows us an interactive tree map to help us determine where all the code is coming from, in addition to the size of the bundles that are emerging from both the external dependencies and the inner code.

Get hands-on with 1200+ tech skills courses.