Built-In Javascript

How to disable loading yii.js and jquery in Yii2 and why it loads by default?

Edit your AppAsset and remove YiiAsset from depends section.

And don’t use grids and forms.

It loads by default because it’s required for all that.

Thanks Alexandr,

I have tried it before, but it has not effect, maybe not all forms has removed.

But it very strangely because Yii is php framework, not js, for example rails doesn’t load jquery until I configure gem file.

Would be good if loading of special scripts and css after they were configured and widgets will be as additions

Yii doesn’t load anything until you ask it to do so, or the requirements needs to be satisfied.

For example, ActiveForm uses client-side validation, so it loads a couple of js scripts.

Anyway, if you need to load your own version of js files, read the docs about assets management, it’s all there.

PS. Also you can disable loading of bundle scripts, but it’s not recommended, so I will not tell you how it’s done :P

I don’t use form validation and active form, I rechecked it.

I don’t need to load own versions of js, I need to load other js and I use assets config for that reason, but in this AppAssets.php I haven’t configured about jquery… but jquery has been loaded :( Now I use standart yii2 layout without navbar

I think the right way is to explicitly specify the jquery in AppAssets.php, instead of loading it as dependency at every opportunity…

Then you use something, that requires JqueryAsset as dependency.

Srsly, you’re missing something.