['js' => [],'sourcePath' => null,]," to remove the jquery script."/> ['js' => [],'sourcePath' => null,]," to remove the jquery script.">

Home >PHP Framework >YII >How to remove jquery in yii2

How to remove jquery in yii2

藏色散人
藏色散人Original
2023-02-17 09:55:591712browse

yii2 Method to remove jquery: 1. Edit the AppAsset.php file and comment out the "yii\web\YiiAsset" value in the variable $depends; 2. Edit the main.php file and under the field "components" Add the configuration "'yii\web\JqueryAsset' => ['js' => [],'sourcePath' => null,]," to remove the jquery script.

How to remove jquery in yii2

The operating environment of this article: Windows 10 system, version yii2.0, Dell G3 computer.

yii2 How to remove jquery?

Completely disable the built-in Yii, JQuery and Bootstrap scripts in Yii2 [Version 2.0]

By default, Yii2 Scripts and styles such as Yii, JQuery and Bootstrap are automatically loaded, but sometimes these libraries may not be needed in the project, or other versions are used; here is how to remove these library scripts and styles.

▪ Remove Yii.js related scripts

Edit the frontend\asset\AppAsset.php file and comment out the 'yii\web\YiiAsset' value in the variable $depends.

Edit the frontend\config\main.php file and add configuration under the field 'components':

'assetManager' => [
 'bundles' => [
     'yii\web\YiiAsset' => [
         'js' => [],  // 去除 yii.js
         'sourcePath' => null,  // 防止在 frontend/web/asset 下生产文件
     ],
                        
     'yii\widgets\ActiveFormAsset' => [
         'js' => [],  // 去除 yii.activeForm.js
         'sourcePath' => null,  // 防止在 frontend/web/asset 下生产文件
     ],
        
     'yii\validators\ValidationAsset' => [
         'js' => [],  // 去除 yii.validation.js
         'sourcePath' => null,  // 防止在 frontend/web/asset 下生产文件
     ],
 ],
],

▪ Remove JQuery script

Edit frontend\config\main.php file, add configuration under the field 'components':

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'js' => [],  // 去除 jquery.js
            'sourcePath' => null,  // 防止在 frontend/web/asset 下生产文件
        ],
    ],
],
  • Remove Bootstrap library

Edit frontend\asset\AppAsset.php file, comment Remove the 'yii\bootstrap\BootstrapAsset' value in the variable $depends.

Edit the frontend\config\main.php file and add the configuration under the field 'components':

'assetManager' => [ 'bundles' => [     'yii\bootstrap\BootstrapAsset' => [         'css' => [],  // 去除 bootstrap.css
         'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件
     ],     'yii\bootstrap\BootstrapPluginAsset' => [         'js' => [],  // 去除 bootstrap.js
         'sourcePath' => null,  // 防止在 frontend/web/asset 下生产文件
     ],
 ],


],

Recommended: "yii tutorial

The above is the detailed content of How to remove jquery in yii2. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn