The JS assests that gets renders looks like this:
<script src="/assets/a00ccd3f/jquery.min.js"></script>
I need to add the async="async"
tag to it.
so it should look like
<script src="/assets/a00ccd3f/jquery.min.js" async="async" ></script>
How can i do this?
In your own AssetBundle you can add
public $jsOptions = [
'async' => 'async',
];
If you want to add this to the Yii2 JqueryAsset bundle (or some other bundle) you can add it to the components parts of your config:
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'jsOptions' => [
'async' => 'async'
],
],
],
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With