Answer the question
In order to leave comments, you need to log in
How to output js script before closing tag in yii2?
Hello, I need to put the js script before the closing body tag, because I need to put it after the js code of the third-party extension, which always comes after my script. And I need it the other way around
I immediately write that it doesn’t help.
This is how I connect the js file to the view, the line above this is the same third-party extension
position' => \yii\web\View::POS_END
use zgb7mtr\colorPicker\ColorPicker;
$this->registerJsFile(Yii::getAlias('@web'). '/js/common.js', ['depends' => [\yii\web\JqueryAsset::className()], 'position' => \yii\web\View::POS_END]);
Answer the question
In order to leave comments, you need to log in
You need to make an additional AssetBundle, something like the following:
namespace app\assets;
use yii\web\AssetBundle;
class CommonAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $js = [
'js/common.js'
];
public $depends = [
'zgb7mtr\colorPicker\ColorPickerAsset'
];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question