|
|
|
@ -65,7 +65,7 @@ class Index extends CI_Controller {
|
|
|
|
|
$js_jquery_content = '';
|
|
|
|
|
foreach ($html_object->find('script') as $link_script) {
|
|
|
|
|
if (!empty($link_script->src)) {
|
|
|
|
|
if(empty($link_script->defer)){ //没有defer标记的才处理,否则让js延后加载
|
|
|
|
|
if(empty($link_script->defer) && empty($link_script->async)){ //没有defer标记的才处理,否则让js延后加载
|
|
|
|
|
$link_js_array[] = $link_script->src;
|
|
|
|
|
$link_script->outertext = ''; //删除链接,移动到页底
|
|
|
|
|
}
|
|
|
|
@ -122,7 +122,7 @@ class Index extends CI_Controller {
|
|
|
|
|
|
|
|
|
|
$js_content = $js_scr_content . $js_jquery_content;
|
|
|
|
|
//延迟加载js,需要把返回的js代码保存到一个文件中,然后替换占位符,以便加载js文件
|
|
|
|
|
$lastload_js.='<script async="async" src="##DEFERSCRIPTDEFER##"></script>';
|
|
|
|
|
$lastload_js.='<script async src="##DEFERSCRIPTDEFER##"></script>';
|
|
|
|
|
$lastload_js.=$js_inline_content;
|
|
|
|
|
|
|
|
|
|
$html_object = str_replace('</body>', $lastload_js . '</body>', $html_object);
|
|
|
|
|