Reference GitHub file in jsFiddle

kaiser picture kaiser · Mar 23, 2012 · Viewed 13.5k times · Source

Is there a possibility to misuse grab files from a github repo as external resources in jsFiddle?

Answer

Ian picture Ian · Jul 3, 2014

TLDR; Visit rawgit.com which will pop your files on a CDN straight from GitHub so you can use them.

Unfortunately none of the answers here worked for me. The rawgithub URL didn't seem to work as the connection gets refused. So here's a full solution that did work. Firstly in GitHub you need to click the Raw button to get the original JavaScript.

enter image description here

Then copy the URL from the page it takes you too. You'll notice if you try and use this directly you'll get a warning from JSFiddle.

enter image description here

More to the point is the browser will give you an error, e.g.:

Refused to execute script from https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

Take that URL and visit rawgit.com. This will give you a URL of the format https://rawgit.com/nnnick/Chart.js/master/Chart.min.js which you can then use.

I've tried and tested this and it seems to work fine without issue