Use minified version of jquery

New to yii2, so im trying to find a way to change the jquery file, to a minified version. I cant find a lot about this but heres what I found in the code…

I have tried to change the stuff below but when i look in the code it will still use the normal version of jquery.

composer.lock




{

            "name": "bower-asset/jquery",

            "version": "2.2.4",

            "source": {

                "type": "git",

                "url": "https://github.com/jquery/jquery-dist.git",

                "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72"

            },

            "dist": {

                "type": "zip",

                "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/c0185ab7c75aab88762c5aae780b9d83b80eda72",

                "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72",

                "shasum": ""

            },

            "type": "bower-asset-library",

            "extra": {

                "bower-asset-main": "dist/jquery.js",

                "bower-asset-ignore": [

                    "package.json"

                ]

            },

            "license": [

                "MIT"

            ],

            "keywords": [

                "browser",

                "javascript",

                "jquery",

                "library"

            ]

        },

Imho, easiest way is to do this through configure your own assets:

  1. Remove yii\web\YiiAsset from main AppAsset and add your own app\assets\YiiAsset line:



<?php

namespace app\assets;

class AppAsset extends AssetBundle

{

    public $basePath = '@webroot';

    public $baseUrl = '@web';

    public $css = [];

    public $js = [];

    public $depends = [

        // 'yii\web\YiiAsset', // remove this

        'app\assets\YiiAsset', // add this

        'yii\bootstrap\BootstrapPluginAsset',

    ];

}



  1. Create app\assets\YiiAsset:



<?php

namespace app\assets;

class YiiAsset extends AssetBundle

{

    public $sourcePath = '@yii/assets';

    public $js = [

        'yii.js',

    ];

    public $depends = [

        'app\assets\JqueryAsset', // here we link to our new JqueryAsset

    ];

}



  1. Create app\assets\JqueryAsset:



<?php

namespace app\assets;

class JqueryAsset extends AssetBundle

{

    public $sourcePath = '@bower/jquery/dist';

    public $js = [

        'jquery.min.js', // here main goal

    ];

}



P.s. This code was not tested. And of course you need to set correct namespaces