I think I found the problem. I was procrastinating a bit and downloaded Opera on here.
The getUserAgent() function (which was right in front of my face this whole time) is *almost* never going to return a match so it will fall under the else clause:
// this line is overwriting script var that's set above that has src = pending.url
// I don't understand what this next line is trying to accomplish at all... (is this for debug?)
With it commented out like that, it seems to work with no errors.
Note the comments I added. The script variable was just getting overridden after it's src element was set, since we were re-creating the element.
Is this whole thing for performance loading the libraries? I'd think they'd just get cached after the first request... (unless it's IE and you're sending the pragma header)
Also, one other thing I also noticed -- it seems you're not closing the body and html tags in the document, at all?
I checked this twice with two browsers to make sure but it looks like that's really the case.