What is the difference between `import()` dynamic import and static `import` in ES modules?

JavaScript Developer Hard

JavaScript Developer — Hard

What is the difference between `import()` dynamic import and static `import` in ES modules?

Key points

  • Dynamic import returns a Promise and can be used conditionally
  • Static import is synchronous and cannot be conditionally used
  • Dynamic import enables code splitting and lazy loading
  • Static import is resolved at parse time

Ready to go further?

Related questions