My web pages pause at ads for a moment. Why?
How to fix it
<div id="ad-0"> <!-- the first ad goes here --> </div> <div id="ad-1"> <!-- a second ad goes here --> </div>
display set to
none so your ads won’t briefly appear at the bottom of the page.
document.getElementById to find the ad and the placeholder, then it uses
appendChild to move the ad into the placeholder div.
How well does it work?
Consider this entire site a live tech demo. Refresh the page and watch under the “Advertisements” header of the sidebar. After all of the content is loaded, the ads pop into place.
It breaks my layout!
With this setup, the placeholders initially take up no space, so they expand when the ad gets loaded. If this breaks your layout, you can set the height and width of the placeholder to the dimensions of the ad like this:
<div id="ad-0" style="width: 125px; height: 125px"> <!-- this placeholder takes up space! --> </div>
Edit (A bit later, still June 4)
Apparently, this is what I get for writing a post about AdSense. See? This is why we can’t have nice things.