<?php
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/core.js' /* <-- added by me */
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
?>
the rendering order on the resulting HTML-page is the following:
There has to be something wrong with the asset dependencies…
Regards
EDIT:
Using both methods the dependencies are somewhat right. The registerJSFile() is rendered after the AppAsset class core.js file. The original dependency (bootstrap) is still wrong.
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/core.js',
];
public $depends = [
'yii\web\YiiAsset',
/*'yii\bootstrap\BootstrapAsset',*/
'yii\bootstrap\BootstrapPluginAsset', // <- using this instead
];
}
?>
Somehow the yii\bootstrap\BootstrapPluginAsset (the bootstrap.js file) gets included, which has yii\bootstrap\BootstrapAsset as a dependency. It seems, as both \BootstrapPluginAsset and the original \AppAsset have \BootstrapAsset as a dependency (and the \BootstrapPluginAsset is maybe added at some point later), their only requirement is to be placed after yii.js…