JSS Minify - Minify JavaScript online to reduce code size and load website faster
Make your website smaller and faster to load by minifying the JS and CSS code.
This minifier removes whitespace, strips comments, combines files, and optimizes/shortens a few common programming patterns.
And it comes with a huge test suite.
If there is one thing you can do to your website, it's turning on compression. For average pages, like 100k of HTML, CSS, or JS can turn into 20k with the help of minification. It downloads faster and the perception of speed by the user from "click to render" will increase.
use MatthiasMullie\Minify;
$sourcePath = '/path/to/source/css/file.js';
$minifier = new Minify\JS($sourcePath);
// we can even add another file, they'll then be
// joined in 1 output file
$sourcePath2 = '/path/to/second/source/css/file.js';
$minifier->add($sourcePath2);
// or we can just add plain js
$js = 'var test = 1';
$minifier->add($js);
// save minified file to disk
$minifiedPath = '/path/to/minified/js/file.js';
$minifier->minify($minifiedPath);
// or just output the content
echo $minifier->minify();