This may be a stupid question, but I will take risks.
On my site, I include the following script file:
<script src="http://connect.facebook.net/en_US/all.js"></script>
This will usually work fine. However, when I work, we have a firewall that blocks any traffic for facebook.com or facebook.net, because obviously no employee has enough self-control to not allow themselves to play Farmville all day, and not work .
This way, when the script loads, it actually produces a bunch of HTML indicating that the site is blocked. Since this is HTML and invalid Javascript, the browser throws script errors. Notice, I still get HTTP 200, so I cannot catch errors this way.
I agree that this is an extreme case, since only a small percentage of users will try to access my site because of a firewall that blocks Facebook traffic, but I still wonder if there is anything relative I can do to check so that the link returns valid Javascript or perhaps surrounds the loading of the script in a giant try / catch block and correctly handles errors. Any ideas would be greatly appreciated!
UPDATE:
Here are the HTTP headers from the firewall error page. Perhaps I can look at the heading for "content-type", which I suppose will 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
source share