I have this legacy code from a client, the code is used to dynamically write ad content on their site. We’re redesigning the clients site and you guessed it; they want us to re-use this legacy code.

The problem? As so many others in my position have surely found, is the legacy code sucks. For you web programmers out there, try this on for size:


document.write ('<script LANGUAGE=JavaScript>\n');

Check out the file for yourself, directly from the 3rd party‘s site. If you’re curious, the 3rd Party is www.247realmedia.com.

Ok, some of you may think this is harmless… think again and think about context here. We’re attempting to write a script tag from within a script tag. Doesn’t this seem wrong to you? It should.

Now, it’s not necessarily the clients code here. Actually, it’s a 3rd party. Yes, that’s correct; the client is paying someone else for this code. That’s just wrong!!!

Why is it there is so much product out there that is quite simply crap and why is it that this crap sells. It just doesn’t make sense.

Lastly, the code above works but not in all cases. Specifically, if you don’t specify a DOCTYPE then the browser (in quirks mode) simply let’s you get away with poor (that’s being generous) code. The moment you specify a DOCTYPE all this poor code crumbles.

As you can imagine, the clients old site; 1) didn’t specify a doctype and 2) was littered with crappy code. Unfortunately it worked, cause now in the integration stages of this redesign we’re coming across these issues. And at the moment I’m tasked with solving the problem of 3rd party code that is securely entrenched in the applications, code that we have little control over as it’s dynamically generated. The best solution in this case would likely be to scrap the 3rd party code but that doesn’t appear to be an option.

Ahh… life without standards.

UPDATE:

To add to the cause, the following code was also in the javascript file.


document.write ('<NOSCRIPT>...

Seriously, what’s the point?

Comments are closed.