How to add bootstrap.js in Magento 2?

Magento 2 Development

Adding bootstrap.js in Magento 2 requires several steps to be done.

First of all, you should create the following module folder structure:

Then, it is necessary to create module files:

registration.php

module.xml

requirejs-config.js

default.xml

default_head_blocks.xml

Now, you have to enable Module (SSH to Magento root):

And deploy static resources (SSH to Magento root):

Note that,

 

RequireJS will not load any JavaScript module source file until someone uses that JavaScript module as a dependency.

Alan Storm

CMS Page example:

More tips from Magento 2 Cookbook

Source (Magento Stackexchange Question) (Joshua34com)