Last active
August 29, 2015 14:10
-
-
Save raamdev/1d88d0b5a37d0a461577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(-1); | |
ini_set('display_errors', TRUE); | |
/* --- Config. section. ----------------------------------------------------------------------- */ | |
$url = 'http://yoursite.com/'; // Swap this out when testing. | |
// Install the HTML Compressor locally, and change the following path as necessary. | |
require_once $_SERVER['WEBSHARK_HOME'].'/websharks/html-compressor/html-compressor/stub.php'; | |
/* -------------------------------------------------------------------------------------------- */ | |
$html_compressor_options = array( | |
'css_exclusions' => array(), | |
'js_exclusions' => array('.php?'), | |
'cache_expiration_time' => '14 days', | |
'cache_dir_public' => sys_get_temp_dir(), | |
'cache_dir_private' => sys_get_temp_dir(), | |
'cache_dir_url_public' => 'http://example.com/htmlc/cache/public', | |
'current_url_scheme' => 'http', | |
'current_url_host' => parse_url($url, PHP_URL_HOST), | |
'current_url_uri' => parse_url($url, PHP_URL_PATH), | |
'compress_combine_head_body_css' => TRUE, | |
'compress_combine_head_js' => TRUE, | |
'compress_combine_footer_js' => TRUE, | |
'compress_inline_js_code' => TRUE, | |
'compress_css_code' => TRUE, | |
'compress_js_code' => TRUE, | |
'compress_html_code' => FALSE, | |
'benchmark' => FALSE, | |
'product_title' => 'HTML Compressor', | |
'vendor_css_prefixes' => array('moz', 'webkit', 'khtml', 'ms', 'o') | |
); | |
$html_compressor = new \websharks\html_compressor\core($html_compressor_options); | |
$compressed_html = $html_compressor->compress(file_get_contents($url)); | |
echo $compressed_html; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment