View Full Version : Delay external script

06-17-2007, 09:48 PM
Hi everyone! I'm new to the site and could use a little help. Here's the issue:

I have a script i'm including on my page but I'm concerned with the time it may take to download. This script calls an ad server which can serve up any number of objects (image, flash, more javascript). Sometimes this can take a few seconds to download and the page doesn't render anything until thats complete. Here's kinda what I'm doing...

<script type="text/javascript" src="http://myadserver" id="SlowBannerAd" />

<!--All my wonderful content-->

What I'd like to do is somehow delay this event from happening until the rest of the page has rendered. Any ideas? Thanks!

06-18-2007, 12:04 AM
You have a few options. Putting the script tags towards the bottom of your document before the closing </body> tag though some browsers load differently. Another option would be to use setTimeout to append the javascript to the document dynamically using the DOM. The DOM is a little more work but not much.