Search results

Tree Shaking

04 Feb 2022 / 1 minute to read

The Tree Shaking process basically reduces the download size of an application over network.

OverView

This article provides the details on what Tree Shaking is and how it works in an Angular application.

Tree Shaking Concept

Tree Shaking is a way to remove unused modules from the final bundle file of the application. Angluar CLI by default uses WebPack bundler for bundling the script files which supports Tree Shaking from WebPack2.

Tree Shaking with Angular

Latest bundlers, compines the complete application scripts into single bundle file. The bundle file dose not contain any export and supports the removed of unused code.

Using Syncfusion with Tree Shaking

By default, Syncfusion Angular components supports Tree Shaking and it dose not require any special changes in application level.

Compiling Angular Application with Tree Shaking

The following steps explains how to run Tree Shaking in an Angular Application.

  1. Create an Angular application with Syncfusion EJ2 Angular components as in the Getting Started documentation using Angular CLI.
  2. Run the ng build --prod or ng serve --prod command to build or serve the application with Tree Shaking enabled.