Yii2: Remove core js loaded twice

Created on 17 Jan 2015  路  3Comments  路  Source: yiisoft/yii2

Hello!
Is there any way to remove js script from renderAjax, which is already loaded?

First of all I mean this:

<script src="/assets/.../jquery.js"></script>
<script src="/assets/.../yii.js"></script>

In Yii1 i could play with Yii::app()->clientScript->scriptMap['jquery.js'] = false;
But what about right way with bundles? Maybe there is an option to avoid this globally in the app?

Most helpful comment

Ok, thanks. I did like this in specific ajax-view

Yii::$app->assetManager->bundles['yii\web\JqueryAsset'] = false;
Yii::$app->assetManager->bundles['yii\web\YiiAsset'] = false;

And it works now

All 3 comments

You should use foro for this questions.

Try :

'components' => [
'assetManager' => [
'bundles' => [
'yiiwebJqueryAsset' => false,
],
],
],

See https://github.com/yiisoft/yii2/blob/master/docs/guide/structure-assets.md for more details.

Ok, thanks. I did like this in specific ajax-view

Yii::$app->assetManager->bundles['yii\web\JqueryAsset'] = false;
Yii::$app->assetManager->bundles['yii\web\YiiAsset'] = false;

And it works now

The js files aren't loaded twice (or more).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Faryshta picture Faryshta  路  48Comments

gpoehl picture gpoehl  路  47Comments

deecode picture deecode  路  50Comments

sapsxxxil picture sapsxxxil  路  50Comments

alexraputa picture alexraputa  路  53Comments