延迟加载google广告和add this社媒插件

ct-mobile-first
ycc 5 years ago
parent 2d5f985ddd
commit 1319b140bc

@ -666,7 +666,8 @@ class Information extends CI_Controller
//信息推荐
$template_NEXT = $this->call_mobile_template_NEXT($template_path, $information->is_id);
$template = str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template);
$template = str_replace('<!--@ADDTHIS-WIDGET@-->', '<script async src="https://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-52170b0a4a301edc"></script>', $template);
$addthis_widget=$this->load->view($template_path.'-add-this', false,true);
$template = str_replace('<!--@ADDTHIS-WIDGET@-->', $addthis_widget, $template);
} else {
$template = str_replace('<!--@PRODUCT-JS@-->', '<script src="https://data.chinahighlights.com/js/flatpickr.js"></script>', $template);
}
@ -708,7 +709,8 @@ class Information extends CI_Controller
$template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
}
if (!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
$template = str_replace('<!--@IN-ARTICLE-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4231674166786366" data-ad-slot="5442695494"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
$in_article_google=$this->load->view($template_path.'-google-ad', false,true);
$template = str_replace('<!--@IN-ARTICLE-GOOGLE@-->', $in_article_google, $template);
}
//社媒分享图片
if (!empty($information->ic_photo)) {

@ -284,6 +284,7 @@
</div>
<!--@PRODUCT-JS@-->
<!--@ADDON-JS@-->
<script>function loadScriptByAsync(src) {var asyncScript = document.createElement("script");asyncScript.async = true;asyncScript.crossorigin = "anonymous";asyncScript.src = src;firstScript=document.getElementsByTagName("script")[0];firstScript.parentNode.insertBefore(asyncScript, firstScript);}</script>
<!--@IN-ARTICLE-GOOGLE@-->
<!--@ADDTHIS-WIDGET@-->
</body>

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save