I have some ads on my website that slow its loading. Someone gave me some code to delay the loading so that it puts a placeholder in place, loads the page and then substitutes that placeholder with the correct javascript ad.

When I load my webpage, I can see the 300x250 placeholder there, but the advert never shows. Have I put my code in the wrong area or something? Or is the code wrong? Any alternative solution to achieve my goal?

I believe what you are attempting to do should work, however, are you sure you have your advertiser URL correct? When I load the page and I commented out your custom onload event, I still end up with a blank page.

I'd check your script tag for your advertiser, as I think your URL is incorrect, as it returns a broken image (image not found).

As a proof-of-concept, I used the Sitepoint logo to prove your code should work:

I have tried numerous methods to make my sites load just that little bit more faster.

As far as adverts and images are concerned then I read somewhere that storing and including the files on a subdomain of your main site has the effect that the files are queued. This results in the page is displayed and the included subdomain images, javasript files, etc fill in the blanks.

Google on something like "subdomain page speed faster" and see what you can find.

I wouldn't want to alter the adsense loading but the other third party ads, like ContextWeb.

Yes, I've used pingdom and other tools but the thing is the adverts. That is the delay.

I haven't tried the code yet as I wanted to see if it is supposed to delay loading of javascript first.

If ContexWeb is the main culprit that is making the page load very slow then I would be tempted to not load the page the first time a punter arrives at the site but to load ContexWeb on all subsequent pages:

test for a $_SESSION['counter'] variable
if $_SESSION['counter'] does not exist
then
$_SESSION['counter'] to TRUE
else
load the ContextWeb advert script

I would also be tempted to load the ContextWeb from a subdomain which should load the script in parallel. As far as I understand loading all scripts and images from subdomains is beneficial until a certain threshold is reached (about a dozen scripts/images) and then the load times have a negative effect.

>>> I haven't tried the code yet as I wanted to see if it is supposed to delay loading of javascript first.The script I supplied will only work on a small page where a fixed position can be applied to the page.

I am already using a cdn for images and other bits. Does that make any difference to the subdomain thing as I'm wondering if the browser is already therefore using one of the pipes.

I think my host is relatively slow and read about speeding up page loading by storing the CSS, Javascript, adverts, images files on a subdomain to take advantage of the parallel loading.

I also use a CDN and page caching, check my signature for links to see if the page loads and displays an outline with text content before loading the thumbnails and Google Adverts. Does the site seem fast or slow? Also check the source files of the thumbnails.

I noticed your site is rather complex. I would be tempted to save one of the slow loading page contents to a static file and then to try and optimise the load time for the static page. Also monitor and log each optimisation.