User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,943 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1364 | Replies: 3
Reply
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 109
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Delay loading advertisements

  #1  
Aug 27th, 2006
Is there ANY method to delay the loading of 3rd party javascript advertisements until the rest of the page has finished loading? When my ad server gets sluggish, it delays the output of my site, which is killer.

And yes, I already know about using position:absolute to place the JS code at the bottom of the page and absolutely position the ad where I want it. Unfortunately that's really hard to do with my layout, however.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: Carmel, IN
Posts: 67
Reputation: Sailor_Jerry is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
Sailor_Jerry's Avatar
Sailor_Jerry Sailor_Jerry is offline Offline
Junior Poster in Training

Re: Delay loading advertisements

  #2  
Aug 27th, 2006
Try adding the "defer" attribute to the end of your script tags.
i.e.(<script type='"text/javascript" defer>your javascript</script>

With this attribute, the code inside the script tags will only get executed when the page has been loaded completely.
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 109
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Delay loading advertisements

  #3  
Aug 27th, 2006
Thanks. Unfortunately, this only works for script files inside <head>. I've actually just succumbed to the pressure and did a whole bunch of fancy absolute positioning tricks. So we'll see how it goes
Reply With Quote  
Join Date: Aug 2005
Location: Carmel, IN
Posts: 67
Reputation: Sailor_Jerry is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
Sailor_Jerry's Avatar
Sailor_Jerry Sailor_Jerry is offline Offline
Junior Poster in Training

Re: Delay loading advertisements

  #4  
Aug 27th, 2006
Originally Posted by cscgal View Post
Thanks. Unfortunately, this only works for script files inside <head>. I've actually just succumbed to the pressure and did a whole bunch of fancy absolute positioning tricks. So we'll see how it goes


Here is a quick test with the scipt in the body. If you remove defer from the script tag and run the html, you will get a script error.

<html>
<head>
<style>#TestDefer{display:none;}</style>
</head>


<body>
<script language="javascript" type="text/javascript" defer>
alert(document.getElementById('TestDefer').innerHTML);
</script>

<div id=TestDefer >
This Text should display in the alert if defer is present in the script.
</div>
</body>
</html>

Last edited by Sailor_Jerry : Aug 27th, 2006 at 2:34 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC