
This addon allows you to minify your site's CSS & JavaScript when its updated.
Documentation
Installation
- Unzip the download folder and copy the
Minify
directory into yoursite/addons
folder. - Run
php please update:addons
Usage
CSS
In Statamic, you can pull in a theme's default stylesheet like this:
{{ theme:css }}
Whereas, if you want to minify it, you switch out theme
for minify
, like so:
{{ minify:css }}
If you want to minify a stylesheet that is not the default one, you can use it like this:
{{ minify:css src="anotherone" }}
Make sure that you don't include .css
at the end of your filename or it won't work.
JavaScript
In Statamic, you can pull in a theme's default script like this:
{{ theme:js }}
Whereas, if you want to minify it, you switch out theme
for minify
, like so:
{{ minify:js }}
If you want to minify a stylesheet that is not the default one, you can use it like this:
{{ minify:js src="anotherone" }}
Make sure that you don't include .js
at the end of your filename or it won't work.
How it works
- You include a tag inside your template
- The addon then minifies the asset
- The minified version gets saved
- The addon returns the URL of the saved & minified asset
Settings
Output
You can control where the minified versions of the assets are saved to. By default, the folder name is _minify
. It might be a good idea to ignore this directory from version control.