Skip to content

Instantly share code, notes, and snippets.

@wilsonpage

wilsonpage/index.html

Last active Sep 19, 2019
Embed
What would you like to do?
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