I was looking at the bottomless pit of badly-written and malformed javascript that loads on fresnobee.com the other day and noticed a peculiar filename loading multiple times (of-course) in our advertisements: DocumentDotWrite.js. Since I loathe the overuse of document.write on our site, it piqued my interest. I had to see what on earth could be in this ridiculously named script.

function DocumentDotWrite(s){document.write(s);}

It didn’t take long to figure out what this does, but I still haven’t figured out the why. Why in the world would anyone need this? Is it one component of a basic abstraction pattern for different implementations of document.write? It’s certainly not easier to type DocumentDotWrite so it couldn’t be a shorthand. This is where context comes into play. The script tag itself is written by a document.write call which is contained within an iframe which is written by a call to document.write which is loaded by another remote script whose tag is written with a call to… take a wild guess.

If you don’t believe me, here’s the link. I think it’s most likely that the developer who wrote this fine gem was probably high on crack and shouldn’t have been writing javascript in the first place. To the folks over at atdmt.com, and at doubleclick, I have nothing to say besides “I hate you” and you should maybe hire just one real developer. Also, start issuing random drug tests.