Skip to content

Instantly share code, notes, and snippets.

@yene
Created May 27, 2016 14:33
Show Gist options
  • Save yene/a7eef61f4bf6046ad987ea7ffcafd8c0 to your computer and use it in GitHub Desktop.
Save yene/a7eef61f4bf6046ad987ea7ffcafd8c0 to your computer and use it in GitHub Desktop.
JS load fallback on errror
<!DOCTYPE HTML>
<html lang="en">
<head>
<script>
function fallback(e) {
var filename = e.src.split('/').reverse()[0];
document.write('<script src="/libs/' + filename + '"><\/script>');
}
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.14.2/react.min.js" onerror="fallback(this)"></script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment