4

I removed yiisoft/yii2-bootstrap from composer.json and update composer, removed bootstrap from assets/AppAsset.php, but still loads bootstrap CSS and JS! When I remove <?php $this->head() ?> from layout, CSS doesn't load, but bootstrap.js is loaded!

How to remove all bootstrap assets from Yii2 basic app?

2
  • Are you're using some widgets/packages which depends on bootstrap? Show content of your composer.json. Commented May 21, 2018 at 8:51
  • I remember to install and try a basic app template from github with bootstrap already striped away but can't find it anymore Commented Oct 5, 2018 at 7:59

1 Answer 1

3

In web.php add this code

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'js'=>[]
        ],
        'yii\bootstrap\BootstrapPluginAsset' => [
            'js'=>[]
        ],
        'yii\bootstrap\BootstrapAsset' => [
            'css' => [],
        ],

    ],
],

and remove this line in AppAsset.php

public $depends = [
   'yii\web\YiiAsset',              #REMOVE
   'yii\bootstrap\BootstrapAsset',  #REMOVE
];
Sign up to request clarification or add additional context in comments.

1 Comment

you can add sourcePath=>null in bundles to make sure they don't look into the @bower directory to load the scripts, removing the lines from AppAsset is not compulsory for disabling bootstrap js and css loading

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.