Putting javascript in the middle of the page slows down your start to render time. Here is my solution to have adsense or anything else load last.
(1) Create another position in your template's index.php file after the </html> tag.
Code:
</html>
<jdoc:include type="modules" name="load_last" />
Then using mod_custom create two objects. The first on is just a placeholder, in my case it's in the left column.
(2) Use the edit code and simply place this into the edit box and save it in the left column position.
Code:
<div id="adsense_left_1_placeholder"></div>
(3) Then use mod_custom to create another object using the following code and then set it's position to "load_last".
Code:
<div id="adsense_left_1" style="margin: 12px;">
<script type="text/javascript">
// <![CDATA[
google_ad_client = "pub-xxxxxxxx42314842";
/* 160x600, created 6/19/11 */
google_ad_slot = "xxxxxxxx65";
google_ad_width = 160;
google_ad_height = 600;
// ]]>
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
</div>
<div>
<script type="text/javascript">
// <![CDATA[
try
{
document.getElementById('adsense_left_1').parentNode.setAttribute("id","adsense_left_1_parent");
document.getElementById('adsense_left_1_placeholder').parentNode.appendChild(document.getElementById('adsense_left_1'));
if (document.all)
{
d=document.getElementById('adsense_left_1_parent');
d.style.visibility='hidden';
}
else
{
d=document.getElementById('adsense_left_1_parent');
d.parentNode.removeChild(d);
}
d=document.getElementById('adsense_left_1_placeholder');
d.parentNode.removeChild(d);
}
catch(err)
{
}
// ]]>
</script>
</div>
Once the code runs it changes the position of the adsense code and then cleans up the unused objects.
For some reason IE gives a nice "Operation Aborted" error when it tries to remove the "adsense_left_1_parent" object so for now I'm just hiding it until I find something that works in IE.