How to make Google Adsense load last after the rest of page

佐手、 提交于 2019-12-06 01:46:48

问题


I have a page with Google Adsense ads. Content is to the left and ads are to the right. When the page is downloading it retrieves the content first and then start with the Google Adsense ads. During that time the rest of the page (footer images) is not fetched until the whole ad is completely downloaded.

How can I make all of my page (content, images) load first and the ad load last?


回答1:


You'll have to put the ad code at the bottom of your html (php, asp, whatever) page so that the browser requests that data last. Browsers read from the top of the document to the end of the document and request along the way. I don't think there's any way around that.

You can still place the ad near the top of the page using css. An absolute position, or some crazy floats might be able to do it.




回答2:


There is no need to do this now. AdSense announced that ad requests will not be blocking page content anymore: http://adsense.blogspot.com/2011/03/making-web-faster-for-all-adsense-for.html




回答3:


I think the simplest way would be to use body onload to start a javascript timer which after say 5 seconds will then populate the html of a div placeholder.

If you want to wait for everything to load you will need to keep track of every image, etc in an array.




回答4:


Yep, this is the way to go. I've discussed it in more detail here, with examples:

http://semplicewebsites.com/google-ads




回答5:


The lnk in the other answer:

http://semplicewebsites.com/google-ads

...is definitely the way to go. I had a few issues to do it with jQuery, but this is what I used. I bascially just move the iframe, after a bit of CSS tweaking.

Assume you load the ads at the bottom of the page in a (hidden) div called ads_footer, and you want them to go in a div called ads_inline (as in the example in the link). You can do this:

$(document.ready(
  function() {
    $('#ads_footer iframe').css('position', '')
    $('#ads_inline').append($('#ads_footer iframe'))
  })

No need for any floats or fancy CSS, apart from removing the absolute positioning.



来源:https://stackoverflow.com/questions/487511/how-to-make-google-adsense-load-last-after-the-rest-of-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!