Littlebob
Littlebob

Reputation: 153

How to disable Yii2 pjax asset loading automatically

How can I stop Yii2 from loading the pjax asset file automatically when I use the Pjax widget? I want to load it myself from a CDN. I've tried this:

        'assetManager' => [
            'bundles' => [
                'yii\web\PjaxAsset' => [
                    'js'=>[]
                ],
            ],
        ],

But that doesn't do anything. Any suggestions?

Upvotes: 0

Views: 782

Answers (2)

Lazy Knight
Lazy Knight

Reputation: 1

Alternative you could choose to disable specific asset bundle.

If you want to disable specific asset, use this:

'assetManager' => [
    'bundles' => [
        'yii\web\PjaxAsset' => false,
   ],
]

If you want to disable whole asset bundles, use this:

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

Upvotes: 0

Bizley
Bizley

Reputation: 18021

Use

'assetManager' => [
    'bundles' => [
        'yii\web\PjaxAsset' => [
            'sourcePath' => null,
            'js'=> ['//cdn.url.you/want/to/use']
        ],
    ],
],

Upvotes: 1

Related Questions