I want to add bootstrap javascript to my child theme.

I have created app/design/frontend/<Vendor>/<theme>/requirejs-config.js

In that file I have placed:

var require = {
    shim : {
        "bootstrap" : { "deps" :['jquery'] }
    paths: {
        "bootstrap" :  "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min"  

This doesn't seem to do anything. How do I add scripts properly in a child theme?

1 Answer 1


To use bootstrap you have use data attribute mage-init for example:

    <div class="your-bootstrap" data-mage-init='{"bootstrap": {}}'>
         Now you can use Bootstrap here

For more information how to init scripts take a look at this article http://alanstorm.com/magento_2_javascript_init_scripts/

  • Does this work inside the cms pages? If I wrap a require wrapper around some script it works but the data attribute on a div isn't working.
    – Guerrilla
    Commented Jun 28, 2017 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.