Ticket #484 (closed Patch: wontfix)
Media module option to minify javascript
| Reported by: | SuicidalWeasel | Owned by: | gregmac |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.2 |
| Component: | Modules:Media | Version: | SVN HEAD |
| Keywords: | Media module, minify | Cc: |
Description
I'd like to propose the idea of including an option in the media module to allow for minifying javascript. A few javascript libraries don't support Dean Edward's Packer, so it would be nice to have the option for alternative compression. Although YUI Compressor seems to be the minifier of choice these days, it requires java, which would be difficult to implement consistently across servers. Therefore, I think the php version of Jsmin would be fairly easy to implement and would yield acceptable results.
Note: In my example I've included jsmin in the vendor folder. It seems to me, the packer library option should be handled similarly as well, since 3rd party libraries should be located here.
http://code.google.com/p/jsmin-php/
New option in config:
$config['min_js'] = false;
In media library:
// In js function, after "if ($this->min_js)" statement
if ($this->min_js)
{
$output = $this->_js_minify($output);
}
// New function
public function _js_minify($data)
{
include (Kohana::find_file('vendor','jsmin-1.1.1'));
$jsmin = new JSMin($data);
return $jsmin->min();
}
