How can I add bootstrap JS file to layout or view with AssetBundle?
if I add
public $js = [ 'js/bootstrap.js', ];
to BootstrapAsset it’s work fine but after composer update it will gone.
maybe new AssetBundle? it’s not pretty.
To load bootstrap of jquery asset you have to declare a dependency from your Asset class to jquery or bootstrap:
How to add bootstrap and custom css and js in custom theme in yii2?
In yii2 theme manager not found.
my theme location is web/themes/admintheme
I could do that partially by commenting asests in AppAsset extends AssetBundle
public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ 'css/site.css', ]; public $js = [ ]; public $depends = [ 'yii\web\YiiAsset',
and then directly add files in html main.php.
But i am still looking forward to learn more about assetBundle
When Registering assets, js files included in end of body , is there any way to move to head ?
Add this in asset
public $jsOptions = ['position' => \yii\web\View::POS_HEAD];