This might be a stupid question, but I'll take my chances.
On my site, I include the following script file:
<script src="http://connect.facebook.net/en_US/all.js"></script>
Normally, this would work just fine. However, where I work we have a firewall that blocks any traffic to the facebook.com or facebook.net domains as obviously no employee has enough self-control to prevent themselves from playing Farmville all day long instead of working.
Thus, when the script loads it actually gets a bunch of HTML saying the site is blocked. Since this is HTML and not valid Javascript, the browser pops up script errors. Note, I still get an HTTP 200 so I can't catch errors that way.
I'm willing to accept this is an edge case, since only a small percentage of users would be trying to access my site from behind a firewall that happens to block Facebook traffic, but I still find myself wondering if there's something relatively easy I can do to test to make sure the link returns valid Javascript, or perhaps surround the loading of the script in a giant try/catch block and handle errors gracefully. Any ideas would be much appreciated!
UPDATE:
Here's the HTTP headers from the firewall's error page. Perhaps I can look at the "content-type" header, which I assume would be text/javascript if the content was valid.
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 4774