In my Yii2 application i've a script that need Jquery to be loaded in the head of the page.
I know there's a parameter that can be setted inside AppAssets.php :
public $jsOptions = [
'position' => \yii\web\View::POS_HEAD
];
but this will render all the Javascripts Files on the head of the page. Is possibile to load only Jquery on the head?
Thanks in advance for all the help
You could simply do this in your view, e.g. :
$this->registerAssetBundle(yii\web\JqueryAsset::className(), View::POS_HEAD);
Or if you want to do this for all your page, you could customize JqueryAsset in your components configuration :
'components' => [
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'jsOptions' => [ 'position' => \yii\web\View::POS_HEAD ],
],
],
],
],
Read more about Customizing Asset Bundles.
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