If a project is using a third-party library with multiple components, but only a few are needed, how can tree shaking be utilized for efficiency?
- Import only the needed components from the library in the code.
- Include the entire library as is.
- Manually remove unused components from the library.
- Use a separate smaller library for the required components.
Tree shaking can be leveraged by importing only the necessary components from the third-party library. This way, the bundler can exclude the unused parts during the build process, optimizing the bundle size. The other options are not efficient for tree shaking purposes.
Loading...
Related Quiz
- In ES6, a function parameter's default value can be another function's _________.
- Composition in ES6 involves creating objects by combining multiple __________ that provide functionality.
- In a subclass constructor, the super keyword must be called before accessing _______.
- In a Promise, if an error is not caught, it leads to a(n) ________.
- Can a generator function yield another generator function? If so, how is it achieved?