https://github.com/bleargh45/apache2-filter-minifier-css
CSS minifying output filter
https://github.com/bleargh45/apache2-filter-minifier-css
apache css-minifier minification minify-css mod-perl
Last synced: about 1 year ago
JSON representation
CSS minifying output filter
- Host: GitHub
- URL: https://github.com/bleargh45/apache2-filter-minifier-css
- Owner: bleargh45
- Created: 2021-01-17T20:34:44.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-25T21:45:09.000Z (over 2 years ago)
- Last Synced: 2025-01-29T05:14:06.685Z (over 1 year ago)
- Topics: apache, css-minifier, minification, minify-css, mod-perl
- Language: Perl
- Homepage: http://metacpan.org/release/Apache2-Filter-Minifier-CSS/
- Size: 64.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# NAME
Apache2::Filter::Minifier::CSS - CSS minifying output filter
# SYNOPSIS
```perl
PerlOutputFilterHandler Apache2::Filter::Minifier::CSS
# if you need to supplement MIME-Type list
PerlSetVar CssMimeType text/plain
# if you want to explicitly specify the minifier to use
#PerlSetVar CssMinifier CSS::Minifier::XS
#PerlSetVar CssMinifier CSS::Minifier
#PerlSetVar CssMinifier MY::Minifier::function
```
# DESCRIPTION
`Apache2::Filter::Minifier::CSS` is a Mod\_perl2 output filter which minifies
CSS using `CSS::Minifier` or `CSS::Minifier::XS`.
Only CSS style-sheets are minified, all others are passed through
unaltered. `Apache2::Filter::Minifier::CSS` comes with a list of known
acceptable MIME-Types for CSS style-sheets, but you can supplement that list
yourself by setting the `CssMimeType` PerlVar appropriately (use `PerlSetVar`
for a single new MIME-Type, or `PerlAddVar` when you want to add multiple
MIME-Types).
Given a choice, using `CSS::Minifier::XS` is preferred over `CSS::Minifier`,
but we'll use whichever one you've got available. If you want to explicitly
specify which minifier you want to use, set the `CssMinifier` PerlVar to the
name of the package/function that implements the minifier. Minification
functions are expected to accept a single parameter (the CSS to be minified)
and to return the minified CSS on completion. If you specify a package name,
we look for a `minify()` function in that package.
## Caching
Minification does require additional CPU resources, and it is recommended that
you use some sort of cache in order to keep this to a minimum.
Being that you're already running Apache2, though, here's some examples of a
mod\_cache setup:
Disk Cache
```
# Cache root directory
CacheRoot /path/to/your/disk/cache
# Enable cache for "/css/" location
CacheEnable disk /css/
```
Memory Cache
```
# Cache size: 4 MBytes
MCacheSize 4096
# Min object size: 128 Bytes
MCacheMinObjectSize 128
# Max object size: 512 KBytes
MCacheMaxObjectSize 524288
# Enable cache for "/css/" location
CacheEnable mem /css/
```
# METHODS
- handler($filter)
CSS minification output filter.
# AUTHOR
Graham TerMarsch (cpan@howlingfrog.com)
Many thanks to Geoffrey Young for writing `Apache::Clean`, from which several
things were lifted. :)
# COPYRIGHT
Copyright (C) 2007, Graham TerMarsch. All Rights Reserved.
This is free software; you can redistribute it and/or modify it under the same
license as Perl itself.
# SEE ALSO
- [CSS::Minifier](https://metacpan.org/pod/CSS%3A%3AMinifier)
- [CSS::Minifier::XS](https://metacpan.org/pod/CSS%3A%3AMinifier%3A%3AXS)
- [Apache2::Filter::Minifier::JavaScript](https://metacpan.org/pod/Apache2%3A%3AFilter%3A%3AMinifier%3A%3AJavaScript)
- [Apache::Clean](https://metacpan.org/pod/Apache%3A%3AClean)