1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-11 16:44:44 +02:00

Merge pull request #505 from glensc/jshrink

add jshrink thin wrapper
This commit is contained in:
Steve Clay
2016-06-28 14:58:24 -04:00
committed by GitHub
2 changed files with 49 additions and 1 deletions

View File

@@ -35,7 +35,8 @@
"require-dev": {
"leafo/lessphp": "~0.4.0",
"meenie/javascript-packer": "~1.1",
"phpunit/phpunit": "4.8.*"
"phpunit/phpunit": "4.8.*",
"tedivm/jshrink": "~1.1.0"
},
"suggest": {
"leafo/lessphp": "LESS support",

47
lib/Minify/JS/JShrink.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
/**
* Class Minify\JS\JShrink
*
* @package Minify
*/
namespace Minify\JS;
/**
* Wrapper to Javascript Minifier built in PHP http://www.tedivm.com
*
* @package Minify
* @author Elan Ruusamäe <glen@pld-linux.org>
* @link https://github.com/tedious/JShrink
*
*/
class JShrink
{
/**
* Contains the default options for minification. This array is merged with
* the one passed in by the user to create the request specific set of
* options (stored in the $options attribute).
*
* @var string[]
*/
protected static $defaultOptions = array('flaggedComments' => true);
/**
* Takes a string containing javascript and removes unneeded characters in
* order to shrink the code without altering it's functionality.
*
* @param string $js The raw javascript to be minified
* @param array $options Various runtime options in an associative array
*
* @see JShrink\Minifier::minify()
* @return string
*/
public static function minify($js, array $options = array())
{
$options = array_merge(
self::$defaultOptions,
$options
);
return \JShrink\Minifier::minify($js, $options);
}
}