Dynamically load modules

button.addEventListener('click', event => {
  import('./dialogBox.js')
    .then(dialogBox => {
      dialogBox. open();
    })
    .catch(error => {
      /\*Error handling \*/
    })
});

ES2020 Proposal introduce import() function

Comments