Skip to content

Instantly share code, notes, and snippets.

@khalilovcmd
Created December 19, 2015 15:20
Show Gist options
  • Save khalilovcmd/6193991d9fb0ad240351 to your computer and use it in GitHub Desktop.
Save khalilovcmd/6193991d9fb0ad240351 to your computer and use it in GitHub Desktop.
to import lodash into chrome dev tools console
var el = document.createElement('script');
el.src = "https://raw.githubusercontent.com/lodash/lodash/3.10.1/lodash.min.js";
el.type = "text/javascript";
document.head.appendChild(el)
@dgaeta
Copy link

dgaeta commented Jul 27, 2016

VM123:1 Refused to load the script 'https://raw.githubusercontent.com/lodash/lodash/3.10.1/lodash.min.js' because it violates the following Content Security Policy directive: "script-src assets-cdn.github.com".
(anonymous function) @ VM123:1
<script src=​"https:​/​/​raw.githubusercontent.com/​lodash/​lodash/​3.10.1/​lodash.min.js" type=​"text/​javascript">​</script>​

Any tips on this?

@tmartensen
Copy link

Pull it from a CDN that will give you the correct mime type. Mine works like this:

var el = document.createElement('script');
el.src = "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js";
el.type = "text/javascript";
document.head.appendChild(el);

@Sheremetin
Copy link

Pull it from a CDN - the same problem

@kiwi-lifter
Copy link

Worked fine from the CDN for me using tmartensen's code example in Chrome Canary.

@mindpivot
Copy link

@Sheremetin try removing the "https:" from the URL and prefixing it with just "//"

@flpelluz
Copy link

flpelluz commented Oct 6, 2017

The error is because of trying to inject the code to this page (gist.github.com) - tmartensen's code works fine on any new blank page.

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