JavaScript · Middle · Question 37 of 75

Why do you need dynamic import()?

Explanation

const { Chart } = await import('./chart.js') returns a promise of the module. Bundlers create a separate file that loads only when needed - the basis of code splitting and React.lazy. The module is cached and runs once.

Further reading

Problem with a question

JavaScript · Middle · question 37

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz