*

bgd

  • ***
  • 33 posts
Bxslider slow loading when more than one slider on a page
« on: September 22, 2020, 07:48:50 AM »
Hello,

I noticed that bxslider is loading slow after the google adsense ad is loading when are more than on slider on a page.

The images are one after the other on the page and after all page is loaded then bxslider is completely loaded.

Does anyone else have this problem?


Thank you
« Last Edit: September 22, 2020, 10:19:00 AM by bgd »

*

MB Themes

Re: Bxslider slow loading when more than one slider on a page
« Reply #1 on: September 22, 2020, 02:29:47 PM »
@bgd
Adsense can slow down whole loading, it should be placed as last one, in asynchronous way or theme scripts should be loaded first.
What you see is simply render blocking content (adsense)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

bgd

  • ***
  • 33 posts
Re: Bxslider slow loading when more than one slider on a page
« Reply #2 on: September 23, 2020, 06:20:48 AM »
I found this:


 method 1 -  onscroll event. Ad will load when you scroll the page.


We have to remove <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> from original ad and to place it to an javascript bottom. The remaining code must stay where we want the ad to appear.

Code: [Select]
<script type='text/javascript'>
//<![CDATA[
var la=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===la||0!=document.body.scrollTop&&!1===la)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),la=!0)},!0);
//]]>
</script>

method 2 - noptimize . Ad will load when the content of the page is loaded.

Code: [Select]
<!--noptimize-->
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
<!--/noptimize-->


For me the best method is 2 because I have an ad on the top of the page
I don't know if google adsense accepts that. I found different opinions.
« Last Edit: September 23, 2020, 06:35:39 AM by bgd »

*

MB Themes

Re: Bxslider slow loading when more than one slider on a page
« Reply #3 on: September 23, 2020, 10:03:07 AM »
@bgd
Well, you will see in your stats.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots