Difference between require() and await import()

Viewed 2482

I would like to know the difference between require(x) and await import(x) in terms of code splitting and lazy loading. Are they both the same? If yes, then why does await import(x) exist in the first place as one can use require() statements anywhere he wants. Any in depth answer would be highly appreciated.

2 Answers
  1. import(x) allows you to selectively load only the items you need, so it can help save memory
  2. import(x) can be run asynchronously, so better performance
Related