composer require sensiolabs/minify-bundle
SensioLabs Minify Bundle integrates Minify into Symfony Asset Mapper.
✅ Minify CSS
and JS
files, remove whitespace, comments, and more..
🌍🌍 Reduces the size of your assets by up to 70%
(see metrics below).
🚀🚀🚀 Improves the loading time of your website, and the user experience
.
🎯 Automatically minify
assets during the build process.
📦📦 Stores minified assets in the Symfony cache
.
🌿🌿🌿 Download the Minify binary automatically
from Github.
Asset | Before | After | Diff | Compression | Time |
---|---|---|---|---|---|
Autocomplete.js | 20 kB | 9.2 kB | -54% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 8 ms |
Bootstrap.js | 145 kB | 62 kB | -57% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 10 ms |
Video.js | 2.3 MB | 0.7 MB | -71% | ⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 42 ms |
w3c.org js | 44 kB | 19 kB | -57% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 | 6 ms |
Asset | Before | After | Diff | Compression | Time |
---|---|---|---|---|---|
Autocomplete.css | 3.1 kB | 2.5 kB | -19% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩 | 2 ms |
Bootstrap.css | 281 kB | 232 kB | -18% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩 | 9 ms |
Video-js.css | 53 kB | 47 kB | -12% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜⬜️⬜️⬜️⬜️⬜️⬜️⬜️️🟩🟩 | 4 ms |
w3c.org css | 111 kB | 70 kB | -37% | ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️🟩🟩🟩🟩🟩🟩🟩🟩 | 5 ms |
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
composer require sensiolabs/minify-bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require sensiolabs/minify-bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
Sensiolabs\MinifyBundle\SensiolabsMinifyBundle::class => ['all' => true],
];
Depending on your deployment process, you might want to enable the bundle only in the desired environment(s).
# config/packages/sensiolabs_minify.yaml
sensiolabs_minify:
asset_mapper:
# Minify CSS and JS files
types:
css: true
js: true
# config/packages/sensiolabs_minify.yaml
sensiolabs_minify:
asset_mapper:
# Exclude files
ignore_paths:
- 'admin/*'
- '*.min.js'
# Exclude vendor assets
ignore_vendor: true
# config/packages/sensiolabs_minify.yaml
sensiolabs_minify:
minify:
# Auto-detect the local binary
local_binary: 'auto'
# Specify the local binary path
# local_binary: "/usr/local/sbin/minify"
# Or set false to disable
# local_binary: false
# config/packages/sensiolabs_minify.yaml
sensiolabs_minify:
minify:
# Enable automatic download from GitHub
download_binary: true
# Directory to store the downloaded binary
download_directory: '%kernel.project_dir%/var/minify'
php bin/console minify:install
php bin/console minify:assets css/main.css css/main.min.css
- Minify binary: Timo Dewolf
- Symfony Bundle: Simon André & SensioLabs
The SensioLabs Minify Bundle is released under the MIT license.