Why is jQuery getting loaded in my layout?

Hi, I’m having some trouble removing jQuery from my layout. I’ve been on the docs and searched this forum but still can’t find the answer.

I have searched my project and I can’t find any specific place where jquery is being loaded. However If I remove


AppAsset::register($this);

from views/layouts/main.php It is no longer loaded.

I’ve searched through the AssetBundle class and can’t see any mention of jquery. I want to use Yii’s AssetBundle but not jQuery. FYI I’m running 2.0 stable release basic

Many thanks in advance

Ash

Perhaps because of http://www.yiiframework.com/doc-2.0/yii-web-yiiasset.html which has a dependency on Jquery

True but that’s not why it is being loaded into the layout. After a bit more digging I found that registering any script file with:


['position' => \yii\web\View::POS_READY]

Yii will automatically add jQuery to the end of the page body. Hover this can be overridden in config:




'assetManager' => [

            'bundles' => [

                 'yii\web\JqueryAsset' => [

                    'jsOptions' => [

                        'position' => \yii\web\View::POS_HEAD

                    ],

                ],        

            ],

        ],



Also worth noting - If you want to load in query from CDN you can do that with:




'assetManager' => [

            'bundles' => [

                 'yii\web\JqueryAsset' => [

                    'jsOptions' => [

                        'position' => \yii\web\View::POS_HEAD

                    ],

                    'js' => ['//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'] 

                ],        

            ],

        ],