From 038936b645ac3d85dc9f65da516d64d49e00b263 Mon Sep 17 00:00:00 2001 From: cyc Date: Mon, 18 Feb 2019 15:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BE=B7=E8=AF=ADamp?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../htmlcompressor/controllers/index_gm.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/application/third_party/htmlcompressor/controllers/index_gm.php b/application/third_party/htmlcompressor/controllers/index_gm.php index 7d5d6062..48d9f4cf 100644 --- a/application/third_party/htmlcompressor/controllers/index_gm.php +++ b/application/third_party/htmlcompressor/controllers/index_gm.php @@ -284,6 +284,7 @@ class Index_gm extends CI_Controller } } + //只将中间主要部分用于css精简,提高速度 foreach ($this->html_object->find('#content_main') as $content_main) { $amp_template = str_replace('', $content_main, $amp_template); } @@ -300,6 +301,10 @@ class Index_gm extends CI_Controller //循环下载所有的css样式,拼接成字符串 foreach ($link_css_array as $item) { + //排除一定不会用到的css,提高精简的速度 + if(strpos($item,'base.css')){ + $item = 'https://data.chinarundreisen.com/min/?f=/css/base.css'; + } $get_http_temp = GET_HTTP($this->format_url($item, $this->websitehost)); if ($get_http_temp == false) { $this->output->set_status_header(404); @@ -310,6 +315,11 @@ class Index_gm extends CI_Controller $css_content .= $get_http_temp; } + foreach ($html_object->find('style') as $style) { + $css_content .= $style->innertext; + $style->outertext = ''; + } + //把网页内容和css提交到purifycss处理 $purifycss_server = 'http://158.177.67.52:33033/'; $optimize_css = GET_HTTP($purifycss_server, 'html_source=' . urlencode($content_main) . '&html_css=' . urlencode($css_content), 'POST');