The default javascript method is to insert a <script type="text/javascript" src="http://server/serve.php"> element to download a small javascript chunk which then inserts
document.write('\x3cdiv class=\"text-advertisement\" id=\"ad-65\"\x3e\x3cdiv class=\"ad-header\"\x3e\x3ca href=\" ...');
However, I find this slows page rendering, especially when there are numerous ad blocks in the content, as each <script> has to wait for the source to be downloaded.
Every Drupal installation should already have a jQuery library being downloaded to every new client. Why not use that?
This patch adds jQuery as another display method. It's kind of a hybrid between javascript and iframes. The page is no longer waiting for each chunk to download before rendering the contents, but we get better control over styles and ads automatically pop in afterwards which helps draw attention to them.
Caveat emptor: There appears to be some optimisation in ad_embed.module (at least on my system) that causes [[ad]] tags with the same parameters to render exactly the same content with the same css ids. This means subsequent instances will not be found by jQuery and will have empty content. If anyone can help track that bug down, I'd appreciate it. I'm running
Drupal 5.7
PHP 5.2.3-1ubuntu6.3 (cli) (built: Jan 10 2008 09:38:37)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with XCache v1.2.1, Copyright (c) 2005-2007, by mOo
| Comment | File | Size | Author |
|---|---|---|---|
| ad-jquery.patch | 3.28 KB | waddles |
Comments
Comment #1
jeremy commentedI am interested in your patch to use jquery, and plan to review it closely after the next release.
Comment #2
jeremy commentedThanks for your patch! A modified version has been committed.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.