The JavaScript used for displaying banners tends to put a large load on the client computer which slows down the client computer. I would like to propose that the JavaScript be turned off when it's not needed.
(Great module, by the way).
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | banner.module.nojs.patch | 5.19 KB | dan_aka_jack |
| #5 | banner.module.2.patch | 5.89 KB | dan_aka_jack |
| #2 | banner.module_3.patch | 5.82 KB | dan_aka_jack |
Comments
Comment #1
dan_aka_jack commentedHmm... I'm trying to submit a patch but I keep getting a "terminated" response from drupal.org... I'll keep trying
Comment #2
dan_aka_jack commentedI've removed the JavaScript call for banner ads.
Before applying my patch, the module displays each banner by outputting this line for each banner:
script type="text/javascript" language="javascript" src="http://mysite.com/banner_file.php?pos=0&path=files&tid=0&max=5"
After applying my patch, the javascript call is removed:
a href="/banner/1" img src="http://mysite.com/files/banners/banner1.png" border=0 width="120" height="120"
(sorry about the formatting... for some reason Drupal.org isn't allowing me to post using the code /code tags)
I developed this patch because the JavaScript call was hurting some other JavaScript on my site.
This patch will prevent rotation.
You can set whether or not the module should use JavaScript in admin/settings/banner
Comment #3
dan_aka_jack commentedComment #4
dan_aka_jack commentedJust to say that banner caching needs to be turned on (and working) for my patch to work
Comment #5
dan_aka_jack commentedHere's a new version of the patch... all I've added is this:
at the top of function banner_file. This fixes a bug where my patch prevented banners from showing on /node/ pages.
Comment #6
wulff commentedI'm not sure I agree with this. The only thing the client computer does is download and run the script generated by one of the cache managers (
banner_db.phporbanner_file.php). The script consists of one call todocument.write(), which shouldn't be too taxing for any recent client.What might slow the client computer down is that it has to wait for the server to return the script before it can finish rendering the page. Using the file cache should make sure that that the response from the server is as fast as possible.
If the JavaScript generated by this module interacts badly with other scripts (I'd love to see an example), I think we're better off changing the script than disabling it altogether, since disabling the JavaScript removes some of the basic functionality of the module (i.e. ad rotation even on cached pages).
Comment #7
dan_aka_jack commentedYes, you're right. That's what was slowing down out site. It wasn't the JavaScript itself, it was the time it took the server to provide the file. It was taking about 1 second.
We use JavaScript to output some flash on our site (see http://ukfilm.org ) - the titles on each news item are Flash. When the javascript was enabled on the banner module, the site would load, then wait a second and then the flash headers would appear. This was ugly.
Comment #8
wulff commentedBefore including this patch, I'd like to get some more opinions on it. As it is, I'm not sure it will go in.
If there is interest in adding this feature, we should probably use the code from banner_db instead of banner_file to choose the banner to display (it is a lot simpler).
Comment #9
dan_aka_jack commentedAh, yes - good idea. I've attached a new patch which used the code from banner_db (this new patch has been made against today's CVS)
Comment #10
wulff commentedMarking as closed since the banner module has been abandoned.