Skip to content

QuizNot attempted

Code splitting

What does a dynamic import() give you over a static import?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • The module is fetched on demand as a separate chunk, so it is not in the initial bundle
  • import() returns a promise and bundlers emit the module as a separate chunk fetched on demand, so it stays out of the initial bundle (React.lazy builds on this).
  • Not faster execution: once loaded the code runs the same.
  • Not tree shaking: static imports are what enable tree shaking
  • dynamic imports make it harder.
  • Not synchronous: it is always asynchronous.