mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-05 09:11:25 +02:00
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
29 lines
594 B
PHP
29 lines
594 B
PHP
<?php
|
|
|
|
namespace SilverStripe\View;
|
|
|
|
use Exception;
|
|
use JSMin;
|
|
|
|
class JSMinifier implements Requirements_Minifier {
|
|
|
|
public function minify($content, $type, $filename) {
|
|
// Non-js files aren't minified
|
|
if($type !== 'js') {
|
|
return $content . "\n";
|
|
}
|
|
|
|
// Combine JS
|
|
try {
|
|
require_once('thirdparty/jsmin/jsmin.php');
|
|
increase_time_limit_to();
|
|
$content = JSMin::minify($content);
|
|
} catch(Exception $e) {
|
|
$message = $e->getMessage();
|
|
user_error("Failed to minify {$filename}, exception: {$message}", E_USER_WARNING);
|
|
} finally {
|
|
return $content . ";\n";
|
|
}
|
|
}
|
|
}
|