Because enabling use of nonces in CSP disables event handlers, it's not possible to add an onerror property to script tags to handle/report asset load issues.
Is there a recommended way to handle this? Particularly for script tags which are not loaded async.
Thanks!
If you dynamically load an external script, you can hang CSP-safe event listeners:
let script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.js"
document.head.append(script);
script.addEventListener('error', function(e) {
// handle onerror event here
});
try creating a separate service that only purpose to monitor, handle, and report/display errors.