perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham TerMarsch <>
Subject RFC: Apache2::Filter::Minifier::JavaScript
Date Wed, 19 Sep 2007 17:24:40 GMT
I've been working on some projects needing JS minification recently and wanted 
to ping others and find out if anyone else would find it useful to have a 
mod_perl2 filter that auto-minified your JS (using JavaScript::Minifier)...

Am thinking along the lines of something that you'd set up in your Apache 
config like:

	<FilesMatch "\.js$">
		PerlOutputFilterHandler Apache2::Filter::Minifier::JavaScript
		PerlSetVar MINIFIER_CACHE_ROOT /path/to/your/cache/dir

Results would be cached to disk, so that we didn't have to re-minify the JS 
files on each and every request.  Obviously, if the original file changes, 
the cached copy would be considered invalid.

Seeing the above makes me wonder, though... is there a way to set up a Perl 
output filter for -just- specific MIME-Types?  Similarly to 
AddOutputFilterByType, but for mod_perl handlers?

Thought I'd ask and see if others would find something like this useful, or if 
you've got suggestions on other ways to do this.  I know that I could just 
minify all the JS files on disk, but it'd be a whole lot simpler to just set 
it up as a filter and not have to worry about it.  Also means that I could 
turn the filter off during testing and be able to work with the un-minified 

Also thinking that an Apache2::Filter::Minifier::CSS module would be possible 
using CSS::Minifier; basically same thing but for CSS instead.

Graham TerMarsch

View raw message