0
0
Angularframework~5 mins

Tree shaking and dead code removal in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is tree shaking in Angular?
Tree shaking is a process that removes unused code from the final bundle during build time. It helps make the app smaller and faster by only including the code that is actually used.
Click to reveal answer
beginner
How does dead code removal improve Angular app performance?
Dead code removal deletes parts of the code that are never called or used. This reduces the app size, leading to faster loading and better user experience.
Click to reveal answer
intermediate
Which Angular build tool feature helps with tree shaking?
Angular uses the Angular CLI with Webpack under the hood. Webpack performs tree shaking by analyzing ES modules and removing unused exports.
Click to reveal answer
intermediate
Why should you use ES modules for effective tree shaking?
ES modules use static imports and exports, which lets build tools know exactly what code is used. This static structure allows tree shaking to safely remove unused code.
Click to reveal answer
advanced
What is a common mistake that can prevent tree shaking in Angular?
Using dynamic imports or requiring modules in ways that are not statically analyzable can stop tree shaking. Also, side effects in code can prevent removal of unused parts.
Click to reveal answer
What does tree shaking do in Angular builds?
AIncreases the app size
BAdds extra debugging information
CRemoves unused code from the final bundle
DChanges the app's runtime behavior
Which module system helps Angular perform tree shaking effectively?
ACommonJS
BUMD
CAMD
DES modules
What tool does Angular CLI use to perform tree shaking?
AWebpack
BGrunt
CGulp
DRollup
Which of these can prevent tree shaking from removing unused code?
ASide effects in code
BUsing Angular components
CStatic imports
DUsing TypeScript
Dead code removal helps Angular apps by:
AAdding more features
BRemoving unused code to reduce bundle size
CMaking the app slower
DChanging the app's UI
Explain in your own words what tree shaking is and why it matters in Angular apps.
Think about how removing unused parts helps your app load faster.
You got /3 concepts.
    Describe how Angular CLI and ES modules work together to enable dead code removal.
    Focus on the build process and module system.
    You got /3 concepts.