NAME
File::HashCache::JavaScript - Minify and cache javascript files based on the hash of their contents.
SYNOPSIS
use File::HashCache::JavaScript;
my $jsh = File::HashCache::JavaScript->new();
my $hashed_minified_path = $jsh->hash("my_javascript_file.js");
# returns "my_javascript_file-7f4539486f2f6e65ef02fe9f98e68944.js"
# If you are using Template::Toolkit you may want something like this:
$template->process('template.tt2', {
script => sub {
my $path = $jsh->hash($_[0]);
"<script src=\"js/$path\" type=\"text/javascript\"></script>\n";
} } ) || die $template->error();
# And in your template.tt2 file:
# [% script("myscript.js") %]
# which will get replaced with something like:
# <script src="js/myscript-708b88f899939c4adedc271d9ab9ee66.js"
# type="text/javascript"></script>
DESCRIPTION
File::HashCache::Javascript is a thin wrapper around the more generic File::HashCache module. It remains here mostly for backwards compatibility. It is recommended that new programs use File::HashCache directly, passing in process_js => \&JavaScript::Minifier::XS::minify
.
SEE ALSO
COPYRIGHT
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2009 David Caldwell and Jim Radford.
AUTHOR
David Caldwell <david@porkrind.org>
Jim Radford <radford@blackbean.org>