Wednesday, May 11, 2011

Ad blocked!

So, I've been working on a project and one of the tasks was to add Advertisement Banner functionality. I used custom php and javascript to create a light-weight Ad display mechanism.
The next part of the project was to add an "AD Rotator" which rotates the displayed Ad every few minutes.
I wrote this class in a separate javascript file included it in the required pages. I almost marked it as completed when I noticed that the rotation script, which was working in localhost, was not working when hosted on the testing server. I was testing in Google Chrome and the Error Console stated:
Uncaught ReferenceError:  start_adRotator is not defined only in chrome
I was pulling my hair over this for almost a day. Good 'ol google was not very helpful here. The same page from the testing server ran perfectly in IE! I mean, my code runs in IE not in Chrome?? Has the fabric of space-time begun to unravel? Is it time to deploy the Amber?...

I was willing to try anything at that point because the project's completion date was near. Time to get debugging. I noticed that my Ad Rotation script was not in the Scripts list box, but present in the "Resources" tab. Hmm... weird, but I didn't think much of it. Next, I tried the Audits tool in Chrome's built-in "Developer Tools". The audit reported that a huge chunk of javascript was not being used. A quick gander at the details revealed that these functions were from the AdBlock plugin that I had installed! *flicker flicker* *flash!*

As the sage Adam Savage once said, "Well, there's your problem!".

After adding an exception to the AdBlock extension, the code works everywhere now. You can rest easy. My lustrous and thick locks are safe, at least for now.

I guess, somehow, when you are the one hosting or displaying Advertisements, you tend not to see them as the annoying, distracting and useless pieces of bandwidth and screen-real estate wasting annoyances of the web that just begs to be blocked!