I want to create a page on my site that has a little Javascript application running, so I want to include .js
and .css
files in a specific view.
I want to create a page on my site that has a little Javascript application running, so I want to include .js
and .css
files in a specific view.
view => site/about.php
// 1
$JS = <<<JS
console.log("hello from yii");
JS;
$this->registerJS($JS, \yii\web\VIEW::POS_END);
// 2
$this->registerJsFile('path/to/your/jsfile');
// css
$this->registerCssFile('path/to/your/cssfile', [
'depends' => [\yii\web\JqueryAsset::class]
]);
Please check the following section of the guide.