diff --git a/application/third_party/htmlcompressor/controllers/index.php b/application/third_party/htmlcompressor/controllers/index.php index 7f5f320c..d089cf0a 100644 --- a/application/third_party/htmlcompressor/controllers/index.php +++ b/application/third_party/htmlcompressor/controllers/index.php @@ -79,16 +79,22 @@ class Index extends CI_Controller { return FALSE; } - //把精简的css添加到head后面 - $html_object = str_replace('', '", $html_object); + //把精简的css添加到head前面 + $html_object = str_replace('', '", $html_object); + //删除多余空格和换行符 + $html_object = str_replace(array(" ", "\t", "\n", "\r"), " ", $html_object); + //循环n次,把双空格替换为一个空格 + for ($i = 0; $i <= 4; $i++) { + $html_object = str_replace(" ", " ", $html_object); + } //在最后加载原始css文件和js文件 - $lastload_js = ''; + $lastload_js.='},1000);'; //把js移动到页面底部 foreach ($link_js_array as $item) { $lastload_js.='';