AppAsset.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace app\assets;
  8. use yii\web\AssetBundle;
  9. /**
  10. * Main application asset bundle.
  11. *
  12. * @author Qiang Xue <qiang.xue@gmail.com>
  13. * @since 2.0
  14. */
  15. class AppAsset extends AssetBundle
  16. {
  17. public $basePath = '@webroot';
  18. public $baseUrl = '@web';
  19. public $css = [
  20. 'css/site.min.css',
  21. 'css/contents.min.css',
  22. 'css/chart.min.css'
  23. ];
  24. public $js = [
  25. 'js/chart.min.js',
  26. 'js/widget2chart.js',
  27. 'js/js.js',
  28. ];
  29. public $depends = [
  30. 'yii\bootstrap4\BootstrapAsset',
  31. 'yii\web\JqueryAsset',
  32. 'yii\web\YiiAsset'
  33. ];
  34. public $jsOptions = [
  35. 'defer'=>true
  36. ];
  37. // public $cssOptions = [
  38. // "rel"=>"preload",
  39. // "as"=>"style",
  40. // "onload"=>"this.rel='stylesheet'"
  41. // ];
  42. public function init()
  43. {
  44. parent::init();
  45. \Yii::$app->assetManager->bundles['yii\\web\\JqueryAsset'] = [
  46. 'jsOptions' => ['position' => \yii\web\View::POS_HEAD, 'defer' => true],
  47. 'js' => ['jquery.min.js']
  48. ];
  49. \Yii::$app->assetManager->bundles['yii\\web\\YiiAsset'] = [
  50. 'jsOptions' => ['position' => \yii\web\View::POS_HEAD, 'defer' => true]
  51. ];
  52. }
  53. }