Adding an external JavaScript to all pages in Drupal 8
To add a JavaScript library to all pages of your Drupal 8 site, you can either add it to your theme or create a module.
This tutorial will demonstrate how one can do it with a module. One reason to do so is to add functionality to your site independent of the theme.