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的内容