I'm using Yii 2.0.9 and it's loading jquery 2.2.4, which I have no problem with. The problem is I've installed the krajee extensions and it's loading jquery 1.7.2, which I don't really want. How can I adjust my AppAssets so that it will fall back to the jquery version that is already being loaded?
1 Answers
First of all, I think that jQuery of different version (1.7.2) is loaded from somewhere else, because Kartik's widgets has separate "base" repository and defines its own AssetBundle which acts as base for widgets and has dependencies only on Yii's core asset bundles:
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
];
Anyway, I see few possible options here.
First, recognize where another version of jQuery is loaded from.
1) If it's in your own code - just remove this dependency.
If it's in vendor module:
2) If jQuery is defined in separate AssetBundle
, you can disable this asset bundle with jQuery like described in answer here.
3) If it's defined as simple reference to file, you can remove it like so:
return [
// ...
'components' => [
'assetManager' => [
'bundles' => [
'used\extension\AssetBundle' => [
'js' => [
'path/to/jquery1.7.2.js', // Remove jQuery 1.7.2 from here (do not include this)
// Extension's other assets
'path/to/extension.js',
],
],
],
],
],
];
Or you can do the same during runtime as decribed in option 2)
4) You can disable extension's AssetBundle
completely using option 2), define your own, customize it as you want (you can subclass existing) and register in desired place.
Read more about assets in official docs.