Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Created March 29, 2014 18:17
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-mapper/9859401 to your computer and use it in GitHub Desktop.
Save max-mapper/9859401 to your computer and use it in GitHub Desktop.
load a <script> tag from a gist raw url
<!doctype html>
<html>
<head>
<style type="text/css">
html, body { margin: 0; padding: 0; }
</style>
</head>
<body>
<script type='text/javascript'>
function loadRaw(gistID) {
var bundleURL = "https://gist.githubusercontent.com/" + gistID + "/raw/minified.js"
var script = document.createElement('script')
script.setAttribute('src', bundleURL)
document.head.appendChild(script)
}
loadRaw('maxogden/9576573')
</script>
</body>
</html>
@taikulawo
Copy link

I have tried use your codes, but console said efused to load the script '*https://gist.****' because it violates the following Content Security Policy directive: "script-src c.s-microsoft.com/mscc/ assets.msn.com assets.msn.cn 'self' www.bing.com/as/ www.bing.com/s/as/ platform.bing.com/geo/AutoSuggest/v1 'nonce-Y2J2NlGO+d0dW6ej5F4E8vgQz41jscUMjUWueD0zn78='". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

@Tylerdclark
Copy link

This might not work now. As a work around, you could use a free service in lieu of a CDN -> rawgithack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment