Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delay external script

    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...

    <html>
    <!--Header-->
    <!--BreadCrumb-->
    <script type="text/javascript" src="http://myadserver" id="SlowBannerAd" />

    <!--All my wonderful content-->
    </html>

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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •