title: Yii2 - How to prevent bootstrap.js from being loaded twice?
body: <p>I'm working on a site which is with yii\bootstrap\BootstrapAsset as a dependency in AppAsset.php</p>
  
  <p>I also need to use flash messages which I'm using with this code:</p>
  
  <pre><code>if (Yii::$app-&gt;session-&gt;hasFlash('success'))
  {
      echo \yii\bootstrap\Alert::widget([
          'options' =&gt; [
              'class' =&gt; 'alert-success',
          ],
          'body' =&gt; Yii::$app-&gt;session-&gt;getFlash('success'),
      ]);
  }
  </code></pre>
  
  <p>However, whenever a flash message is triggered, when checking the console, bootstrap.js is loaded twice and messes up most of the functionalities on the site.</p>
  
  <p>So: how can I prevent bootstrap.js from loading twice whenever a flash message is triggered?</p>
  
  <p><a href="https://i.stack.imgur.com/ezfVS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezfVS.png" alt="bootstrap.js loaded twice"></a></p>