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

How to remove jquery in yii2

藏色散人
Release: 2023-02-17 09:55:59
Original
1701 people have browsed it

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 下生产文件
     ],
 ],
],
Copy after login

▪ 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 下生产文件
        ],
    ],
],
Copy after login
  • 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 下生产文件
     ],
 ],
Copy after login


],

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template