How to exclude in rendering already existing scripts in DOM in Yii2
What method (render or renderAjax etc.) i have to use to exclude rendering one more (the same) jquery, jquery.ui
I have jquery.js on my page. And i (via ajax) load to my page modal window of registration, that requires jquery.js, and it pulls jquery.js second time.
And in the result my page contains 2 jquery.js library. And somewhere starts ocurring errors. I want to fix it by remoeving enother jquery.js
I'm not sure if you are using AssetBundle class but if not - you should.
There is already defined yii\web\JqueryAsset
with jquery.js you can use. Now you can create AssetBundle with your script that will depend on JqueryAsset (read more about assets dependency in the Guide). No matter how many times this asset is registered JqueryAsset will be registered only once.
You can do the same when adding single js file with registerJsFile() - in options array you can use 'depends'
key with the JqueryAsset.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments