CS Fundamentals Trainer · JavaScript · Performance & Memory
A route component is loaded with const Settings = lazy(() => import('./Settings')). What is the main performance effect?
A route component is loaded with `const Settings = lazy(() => import('./Settings'))`. What is the main performance effect?
- The bundler compiles `Settings` to WebAssembly, so it parses and executes faster than plain JavaScript.
- The bundler emits `Settings` as a separate chunk that is downloaded when it is first rendered, shrinking the initial bundle.
- The browser preloads `Settings` in parallel with the main bundle, so the first load fetches the same bytes faster.
- The module runs in a Web Worker, which keeps its execution off the main thread.
Difficulty: medium