Skip to content

Instantly share code, notes, and snippets.

@kylefritz
Created October 4, 2016 01:36
Show Gist options
  • Save kylefritz/2e33223dfd93d25da4a99a25d8d4e557 to your computer and use it in GitHub Desktop.
Save kylefritz/2e33223dfd93d25da4a99a25d8d4e557 to your computer and use it in GitHub Desktop.
check if local webpack server is running; fallback to real s3 asset
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>hello world</title>
<script>
const makeTag = function(src){
let scriptTag = document.createElement('script')
scriptTag.src = src
return scriptTag
}
const developmentTag = makeTag("http://localhost:3000/great-script.js")
developmentTag.onerror = function(){
document.head.appendChild(makeTag("http://my-real-asset.js"))
}
document.head.appendChild(developmentTag)
</script>
</head>
<body>
<h1>why hello</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment