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?

  1. The bundler compiles `Settings` to WebAssembly, so it parses and executes faster than plain JavaScript.
  2. The bundler emits `Settings` as a separate chunk that is downloaded when it is first rendered, shrinking the initial bundle.
  3. The browser preloads `Settings` in parallel with the main bundle, so the first load fetches the same bytes faster.
  4. The module runs in a Web Worker, which keeps its execution off the main thread.

Difficulty: medium

Answer this question

Related questions