What is dynamic import?

The dynamic import() syntax is a ECMAScript proposal not currently part of the language standard. It is expected to be accepted in the near future. You can achieve code-splitting into your app using dynamic import.

Let's take an example of addition,

  1. Normal Import
import { add } from './math';
console.log(add(10, 20));
  1. Dynamic Import
import('./math').then((math) => {
console.log(math.add(10, 20));
});

Author of content
Edit this page

Made by Michael Sakhniuk

Twitter