From 0748f382b03b6a3292bac73d8368a000dd1594a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Mon, 12 Jun 2017 09:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0css=E5=BB=B6=E8=BF=9F?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=EF=BC=8Chtml=E7=B2=BE=E7=AE=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../htmlcompressor/controllers/index.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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.='';