Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
59
rated 0 times [  63] [ 4]  / answers: 1 / hits: 23229  / 10 Years ago, tue, september 16, 2014, 12:00:00

Without Google Ads, my HTTPS webpage loads in about 500ms. With Google Ads, the same webpage takes 2-5 seconds to load. I have two banner ads (one at the top and one at the bottom). Yes, it renders the entire page before the ads, but I still think it's clunky to have the browser spinning while it waits for the ads to finish.



Is there any way with Javascript to finish page loading before the ads, and then just load the ads in the background? Basically, trick it into thinking the entire page is already loaded?



Current code:



<script async src=//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js></script>
<!-- My Ad Banner -->
<ins class=adsbygoogle
style=display:inline-block;width:728px;height:90px
data-ad-client=myid
data-ad-slot=myid></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>


Looking at the waterfall for my site, it doesn't look like the adsbygoogle.js is causing the load indicator. Instead, it's the actual ad content itself. For example, this object (the banner ad) doesn't even start loading until 1.8 seconds (long after my entire page has already loaded): tpc.googlesyndication.com/simgad/AdID



Thanks!


More From » html

 Answers
17

Try this article.


The trick is to put your ad initializing and loading logic in window's onload event:


<script>
window.onload = function(){
...
};
</script>

[#69435] Saturday, September 13, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ernest

Total Points: 332
Total Questions: 92
Total Answers: 98

Location: Armenia
Member since Sat, Dec 31, 2022
1 Year ago
;