From 5b0b0bd208389032cf171568c28694dec039f23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Fri, 11 Aug 2017 14:50:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4defer=E7=9A=84js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/htmlcompressor/controllers/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/third_party/htmlcompressor/controllers/index.php b/application/third_party/htmlcompressor/controllers/index.php index bbf12e44..c2b57b76 100644 --- a/application/third_party/htmlcompressor/controllers/index.php +++ b/application/third_party/htmlcompressor/controllers/index.php @@ -63,8 +63,10 @@ class Index extends CI_Controller { $js_jquery_content = ''; foreach ($html_object->find('script') as $link_script) { if (!empty($link_script->src)) { - $link_js_array[] = $link_script->src; - $link_script->outertext = ''; //删除链接,移动到页底 + if(empty($link_script->defer)){ //没有defer标记的才处理,否则让js延后加载 + $link_js_array[] = $link_script->src; + $link_script->outertext = ''; //删除链接,移动到页底 + } } else { //网页内的js不需要提取 //$js_content.= $link_script->innertext;//js的内容