How to delete a registered jquery file in Yii2

While working with Yii2, I had a problem with jquery files. In the layout, I registered the file jquery-1.10.2.min.js. But on the inner page as usage ActiveForm, then it includes a jquery file from assets.

Is there any way to delete jquery-1.10.2.min.json any page when using ActiveForm?

Many thanks,

M.

+4
source share
1 answer

Yes, you must change the configuration of the assetManager component:

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 custom jquery (no need to register it).

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

+4
source

All Articles