How to load a JavaScript file of a custom module in Magento 2

- Magento 2

Magento 2 Development

To load a JavaScript file of a custom module in Magento 2, you have to include an extension’s base javascript file via layout instructions.

'

Then, require other extension’s JS files from the base file via RequireJS:

Source (Magento Stackexchange Question)(Dmitry Fedyuk)

Other tips from the cookbook

'