title: Detect and log when external JavaScript or CSS resources fail to load
body: <p>I have multiple <code>&lt;head&gt;</code> references to external js and css resources. Mostly, these are for things like third party analytics, etc. From time to time (anecdotally), these resources fail to load, often resulting in browser timeouts. Is it possible to detect and log on the server when external JavaScript or CSS resources fail to load?</p>
  
  <p>I was considering some type of lazy loading mechanism that when, upon failure, a special URL would be called to log this failure. Any suggestions out there?</p>
  
  <p>What I think happens:</p>
  
  <ol>
  <li><p>The user hits our page and the server side processes successfully and serves the page</p></li>
  <li><p>On the client side, the HTML header tries to connect to our 3rd party integration partners, usually by a javascript include that starts with "http://www.someothercompany.com...". </p></li>
  <li><p>The other company cannot handle our load or has shitty up-time, and so the connection fails.</p></li>
  <li><p>The user sees a generic IE Page Not Found, not one from our server.</p></li>
  </ol>
  
  <p>So even though my site was up and everything else is running fine, just because this one call out to the third party servers failed, one in the HTML page header, we get a whole failure to launch.</p>