Optimizing DFP loading

Ive been using DFP (formerly known as Google Ad Manager) to serve ads on my site. I use their Iframe method, where the javascript would write an iframe and allow the third party ad networks to load their ad asyncronously.

But there was still a downside to this.

DFP asks me to put the following code within the part of the page :-



And the following code to load the ads

<script type="text/javascript">GA_googleFillSlotWithSize("ca-pub-xxxxxxxxxxxxxxxxxxxxxxx", "slot_name", 728, 90);</script>

The problem with this is that this makes 3 serial requests to google blocking up the page.

What i did was i moved that chunk to the part of the HTML just before the first time i use the GA_googleFillSlotWithSize() function. The results were astonishing!

My final aim is to rewrite the remplate so the adtags(and the bootstrap code) will be below the content, so that shows up instantly.

If you see the before and after waterfall charts youll see after the change, atleast some images were being downloaded in parallel to these DFP javascript scripts. Even visually , the user got some feedback that the page is loading earlier.

So, next time if some third party asks you to put code within the part, think carefully if it really must go in the ?

In an ideal world, Google would make DFP tagging absolutely asyncronous so it doesnt get in the way of the user and the content.