Skip to content

Instantly share code, notes, and snippets.

@phpfour
Created October 19, 2012 17:45
Show Gist options
  • Save phpfour/3919585 to your computer and use it in GitHub Desktop.
Save phpfour/3919585 to your computer and use it in GitHub Desktop.
Minification script using YUI compressor
<?php
$contentDir = __DIR__ . '/../web/wp-content/' ;
$yuiCompressor = 'java -jar yuicompressor-2.4.7.jar ';
$files = array();
$files[] = $contentDir . "/themes/power/js/libs/jquery.easing.1.3.js";
$files[] = $contentDir . "/themes/power/js/vehicle-finder.js";
$files[] = $contentDir . "/themes/power/js/script.js";
$files[] = $contentDir . "/themes/power/js/reviews.js";
$files[] = $contentDir . "/themes/power/js/home.js";
$output = '';
foreach ($files as $file) {
$output .= shell_exec($yuiCompressor . $file) . PHP_EOL;
}
file_put_contents($contentDir . '/themes/power/js/scripts.min.js', $output);
$files = array();
$files[] = $contentDir . "/themes/power/css/ui-darkness/jquery-ui-1.8.16.custom.css";
$files[] = $contentDir . "/themes/power/css/style.css";
$files[] = $contentDir . "/themes/power/css/power.css";
$output = '';
foreach ($files as $file) {
$output .= shell_exec($yuiCompressor . $file) . PHP_EOL;
}
file_put_contents($contentDir . '/themes/power/css/styles.min.css', $output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment