function minHtml($path) { $html = file_get_contents(getcwd() . $path); $minified_html = PHPWee\Minify::js($html); file_put_contents(getcwd() . $path, $minified_html); }
protected function minifyHTML($html) { require_once 'phpwee.php'; return PHPWee\Minify::html($html); }
<?php require_once "../phpwee.php"; $html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29"); $minified = PHPWee\Minify::html($html); echo print_performance_graph("Wikipedia", $minified, $html); /* $html = file_get_contents("http://www.codeproject.com/Articles/759094/Step-by-Step-PHP-Tutorials-for-Beginners-Creating"); $minified = PHPWee\Minify::html($html); echo print_performance_graph("The Code Project",$minified,$html); $html = file_get_contents("https://github.com/php/php-src"); $minified = PHPWee\Minify::html($html); print_performance_graph("GiHub",$minified,$html); $html = file_get_contents("http://www.w3schools.com/php/"); $minified = PHPWee\Minify::html($html); print_performance_graph("W3Schools",$minified,$html); $html = file_get_contents("http://searchturbine.com"); $minified = PHPWee\Minify::html($html); print_performance_graph("SearchTurbine",$minified,$html); */ /////////////////////////////////////////////////////////////// function print_performance_graph($subject, $minified, $html) { $before = strlen(gzcompress($html)); $after = strlen(gzcompress($minified));