title: How to detect when one or more JS/CSS library fail to load (e.g. CDN)?
body: <p><strong>Premise</strong>: I've found these two answers but I don't understand how I can sistematically apply it for many libraries:</p>
  
  <p><a href="https://stackoverflow.com/questions/5683824/detect-and-log-when-external-javascript-or-css-resources-fail-to-load">Detect and log when external JavaScript or CSS resources fail to load</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10688205/html-if-statement-to-load-local-js-css-upon-cdn-failure">HTML if statement to load local JS/CSS upon CDN failure</a></p>
  
  <p>I've an Augular 1.x application which depends on several libraries, many of them hosted on CDN or external server.
  Unfortunately when the user is offline, the Internet connection doesn't work well or there is a (CDN) server problem, some libraries occasionally fail to download and hence to load.</p>
  
  <p>In this case I want to show the the user a view like "there was an error. Please reload or try later".</p>
  
  <p>My doubts is: Given that the library are simply loaded (<strong>some</strong> of them even <strong>asynchronously</strong>) in <strong>index.html</strong> by:</p>
  
  <pre><code>&lt;link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/angular_material/0.8.2/angular material.min.css"&gt;
  </code></pre>
  
  <p>for <strong>css</strong> (within <strong>head</strong>) and</p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>for <strong>JS</strong> (at the end of <strong>body</strong>)</p>
  
  <p><strong>How can I detect the down(loading) failure of even one single library</strong>? (in fact, let's say it fails to load Angular's because of connection error, the whole app won't work. but I've several mandatory libraries)</p>
  
  <p>Or <strong>should I give priority to reliability</strong>(i.e. loading libraries locally) over performance (i.e. cached CDN)? 
  Also, I think it's important to precise that some libraries (e.g. Google Apis) <strong>can't really be downloaded</strong> or installed via Bower.</p>