×
  • remind me tomorrow
  • remind me next week
  • never remind me
Subscribe to the ANN Newsletter • Wake up every Sunday to a curated list of ANN's most interesting posts of the week. read more

Forum - View topic
JavaScript ads slow down page loads




Anime News Network Forum Index -> Site-related -> Bugs & Technical Questions
View previous topic :: View next topic  
Author Message
PatrickD



Joined: 03 Dec 2003
Posts: 93
Location: California
PostPosted: Sat May 10, 2008 11:02 am Reply with quote
Let me preface this by saying that my "real job" is maintaining an ad server for one of the 100 most popular Internet web sites...

I noticed today that the ANN home page seemed to load rather slowly for me. It got as far as the top navigation when everything came to a halt. My browser's status bar indicated that it was trying to connect to servedby.advertising.com. Eventually it loaded, but the whole page was waiting on that one ad.

Going to the forums just now, I encountered the same wait for another ad.

Viewing the page source, I notice that ads are called in JavaScript. When we tried serving ads via JavaScript a few years back, it was a disaster and we rolled back that change within a day. All it takes is one slow third-party ad server and everything after that ad call will not load until after the ad loads.

The solution we've been using since that time is to call all our ads in an iframe. That way, the page will still display and content won't suffer if some third-party advertiser has a slow ad server. There are some limitations with using iframes (most notably, the fixed size), but we definitely have found it to be the solution that works for us.

Just thought I'd throw in my 2 cents in case you guys were annoyed by the slow-loading ads too.
Back to top
View user's profile Send private message Visit poster's website
Dan42
Chief Encyclopedist


Joined: 02 Jan 2002
Posts: 3782
Location: Montreal
PostPosted: Tue May 13, 2008 11:41 pm Reply with quote
You really got me thinking here.

I had already considered this technique before but it means an additional server hit for every ad. Assuming 2 ads per page, that's literally tripling the number of dynamic requests hitting the server.

Then I realized: it only needs to be for external ads.

Then I realized: it doesn't have to be dynamic; I could pre-generate a static file containing the code for the ad.

Then I realized: maybe I can "inline" the frame's content as base64. Testing:
Code:
<?
echo '<iframe src="data:text/html;base64,';
echo base64_encode('<script>alert(42)</script>');
echo '"></iframe>';
?>

It works! woohoo!

It doesn't work on IE but I think I'm going to be investigating this a little bit more...
Back to top
View user's profile Send private message Visit poster's website AIM Address My Anime My Manga
Display posts from previous:   
Reply to topic    Anime News Network Forum Index -> Site-related -> Bugs & Technical Questions All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group