Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Last active September 19, 2019 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsonpage/7262cf36d155df1aa23bd304d8aaf467 to your computer and use it in GitHub Desktop.
Save wilsonpage/7262cf36d155df1aa23bd304d8aaf467 to your computer and use it in GitHub Desktop.
Detect if a core script failed to load
<html>
<head>
</head>
<body>
<script type="text/javascript">
window.addEventListener('error', function(error) {
if (error.target instanceof HTMLScriptElement) {
const script = error.target;
const isLocalScript = script.src.indexOf(location.host) > -1;
if (!isLocalScript) return;
const shouldReload = confirm('a script failed to load properly, try to reload?');
if (shouldReload) location.reload(true);
}
}, true);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment