Ticket #484 (closed Patch: wontfix)

Opened 8 months ago

Last modified 2 months ago

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();
}

Change History

Changed 7 months ago by SuicidalWeasel

  • type changed from Feature Request to Patch

After finally looking into this some more, I discovered packer can actually minify without encoding by using the option 'None.' This isn't really well documented, even in the packer source code. Therefore, it would be nice to expand the option comment a bit to clarify this.

/**
 * To enable encoding of javascript files, set to: 0, 10, 62, 95, 'Numeric', 'Normal', or 'High ASCII'.
 * To enable minification without encoding, set to: 'None'.
 * To disable javascript packing, set to: FALSE.
 */
$config['pack_js'] = FALSE;

Changed 2 months ago by Shadowhand

  • status changed from new to closed
  • resolution set to wontfix

Media is no longer a supported modules, see KohanaModules.

Note: See TracTickets for help on using tickets.