public function handle($request, \Closure $next) { $final = $next($request); if ($final instanceof Response) { $final->setContent(minify_html($final->getOriginalContent())); } return $final; }
</div> </div> </div> <footer> <p> <span id="copyright">Copyright</span> © 2016 <a id="footer-link" href="<?php echo $base_url; ?> ">Comic Jet</a>. <span id="creation">A creation of</span> <a href="https://geek.hellyer.kiwi/">Ryan Hellyer</a> <a id="legal-notice" href="<?php echo $base_url; ?> legal-notice/" class="alignright">Legal Notice</a> </p> </footer> <input type="hidden" id="refreshed" value="no"> <script src="<?php echo $base_url; ?> minified.js"></script> </body> </html><?php $html = ob_get_contents(); $minified_html = minify_html($html); file_put_contents($base_path . 'public_html/index.html', $minified_html); file_put_contents($base_path . 'public_html/index.html', $html); ob_end_clean();
}, str_replace("\r", "", $input)); // Minify inline CSS declaration(s) if (strpos($input, ' style=') !== false) { $input = preg_replace_callback('#<([^<]+?)\\s+style=([\'"])(.*?)\\2(?=[\\/\\s>])#s', function ($matches) { return '<' . $matches[1] . ' style=' . $matches[2] . minify_css($matches[3]) . $matches[2]; }, $input); } return preg_replace(array('#<(img|input)(>| .*?>)#s', '#(<!--.*?-->)|(>)(?:\\n*|\\s{2,})(<)|^\\s*|\\s*$#s', '#(<!--.*?-->)|(?<!\\>)\\s+(<\\/.*?>)|(<[^\\/]*?>)\\s+(?!\\<)#s', '#(<!--.*?-->)|(<[^\\/]*?>)\\s+(<[^\\/]*?>)|(<\\/.*?>)\\s+(<\\/.*?>)#s', '#(<!--.*?-->)|(<\\/.*?>)\\s+(\\s)(?!\\<)|(?<!\\>)\\s+(\\s)(<[^\\/]*?\\/?>)|(<[^\\/]*?\\/?>)\\s+(\\s)(?!\\<)#s', '#(<!--.*?-->)|(<[^\\/]*?>)\\s+(<\\/.*?>)#s', '#<(img|input)(>| .*?>)<\\/\\1>#s', '#( ) (?![<\\s])#', '#(?<=\\>)( )(?=\\<)#', '#\\s*<!--(?!\\[if\\s).*?-->\\s*|(?<!\\>)\\n+(?=\\<[^!])#s'), array('<$1$2</$1>', '$1$2$3', '$1$2$3', '$1$2$3$4$5', '$1$2$3$4$5$6$7', '$1$2$3', '<$1$2', '$1 ', '$1', ""), $input); } // CSS Minifier => http://ideone.com/Q5USEF + improvement(s) function minify_css($input) { if (trim($input) === "") { return $input; } return preg_replace(array('#("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')|\\/\\*(?!\\!)(?>.*?\\*\\/)|^\\s*|\\s*$#s', '#("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\'|\\/\\*(?>.*?\\*\\/))|\\s*+;\\s*+(})\\s*+|\\s*+([*$~^|]?+=|[{};,>~+]|\\s*+-(?![0-9\\.])|!important\\b)\\s*+|([[(:])\\s++|\\s++([])])|\\s++(:)\\s*+(?!(?>[^{}"\']++|"(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')*+{)|^\\s++|\\s++\\z|(\\s)\\s+#si', '#(?<=[\\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', '#:(0\\s+0|0\\s+0\\s+0\\s+0)(?=[;\\}]|\\!important)#i', '#(background-position):0(?=[;\\}])#si', '#(?<=[\\s:,\\-])0+\\.(\\d+)#s', '#(\\/\\*(?>.*?\\*\\/))|(?<!content\\:)([\'"])([a-z_][a-z0-9\\-_]*?)\\2(?=[\\s\\{\\}\\];,])#si', '#(\\/\\*(?>.*?\\*\\/))|(\\burl\\()([\'"])([^\\s]+?)\\3(\\))#si', '#(?<=[\\s:,\\-]\\#)([a-f0-6]+)\\1([a-f0-6]+)\\2([a-f0-6]+)\\3#i', '#(?<=[\\{;])(border|outline):none(?=[;\\}\\!])#', '#(\\/\\*(?>.*?\\*\\/))|(^|[\\{\\}])(?:[^\\s\\{\\}]+)\\{\\}#s'), array('$1', '$1$2$3$4$5$6$7', '$1', ':0', '$1:0 0', '.$1', '$1$3', '$1$2$4$5', '$1$2$3', '$1:0', '$1$2'), $input); } // JavaScript Minifier function minify_js($input) { if (trim($input) === "") { return $input; } return preg_replace(array('#\\s*("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')\\s*|\\s*\\/\\*(?!\\!|@cc_on)(?>[\\s\\S]*?\\*\\/)\\s*|\\s*(?<![\\:\\=])\\/\\/.*(?=[\\n\\r]|$)|^\\s*|\\s*$#', '#("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\'|\\/\\*(?>.*?\\*\\/)|\\/(?!\\/)[^\\n\\r]*?\\/(?=[\\s.,;]|[gimuy]|$))|\\s*([!%&*\\(\\)\\-=+\\[\\]\\{\\}|;:,.<>?\\/])\\s*#s', '#;+\\}#', '#([\\{,])([\'])(\\d+|[a-z_][a-z0-9_]*)\\2(?=\\:)#i', '#([a-z0-9_\\)\\]])\\[([\'"])([a-z_][a-z0-9_]*)\\2\\]#i'), array('$1', '$1$2', '}', '$1$3', '$1.$3'), $input); } if ($this->getConfig('status') != 'deaktiviert') { rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) { $ep->setSubject(minify_html($ep->getSubject())); }); } }
/** * Write HTML Cache file * @param string $key * @param string $data * @return bool */ public function save_html_cache($key, $data) { $ret = false; if (!$key) { return false; } $group = $this->_get_group($key); if (!is_null($data) && $this->enabled && $this->cache_driver && $this->cache_driver->isSupported()) { $lock = $this->lock($key, $group); if ($lock['locked'] == false && $lock['waited'] == true) { //cache is released, try locking again. $lock = $this->lock($key, $group); } //Minify HTML before saving to cache require_once DIR_CORE . 'helper/html-css-js-minifier.php'; $data = minify_html($data); $ret = $this->cache_driver->put($key, $group, $data); if ($lock['locked'] == true) { //unlock if cache was locked $this->unlock($key, $group); } } return $ret; }
<div class="row"> <div class="col m6 s12"> <a id="loadMore" href="#" class="btn-large white waves-effect center-align black-text" style="width:100%; margin-top:8px;"><i class="fa fa-gear left"></i>Load more trails</a> </div> <div class="col m6 s12"> <a href="#" onClick="getLocation(event);" class="btn-large white waves-effect center-align black-text" style="width:100%; margin-top:8px;"><i class="fa fa-map-marker left"></i>Find trails near you</a> </div> </div> </div> <?php require "/nfs/users/clind/public_html/prescriptiontrails.org/src/drawer.php"; $output = ob_get_contents(); ob_end_clean(); echo minify_html($output); ?> <?php require "/nfs/users/clind/public_html/prescriptiontrails.org/src/js_base.php"; ?> <script> <?php if ($userActive) { ?> var favoritesObj = JSON.parse("<?php echo json_encode(array_values($_SESSION['data']['fav'])); ?> "); <?php