Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove registered jquery file in Yii2

While working with Yii2, I am facing a problem with jquery files. In layout I have registered a jquery-1.10.2.min.js file. But in inner page as use ActiveForm then it includes jquery file from assets as well.

Is there any way to remove jquery-1.10.2.min.js on any page while using ActiveForm ?

Many Thanks,

M.

like image 448
Maverick Avatar asked Jan 19 '15 08:01

Maverick


1 Answers

Yes, you should modify assetManager component config :

return [
    // ...
    'components' => [
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'sourcePath' => null,   // do not publish the bundle
                    'js' => [
                        '//code.jquery.com/jquery-1.10.2.min.js',  // use custom jquery
                    ]
                ],
            ],
        ],
    ],
];

It will load a custom jquery (no need to register it).

Read more : http://www.yiiframework.com/doc-2.0/guide-structure-assets.html#customizing-asset-bundles

like image 88
soju Avatar answered Oct 29 '22 16:10

soju