Above answers clearly answer the question but I want to provide another alternative - A different view/approach to solve the similar problem.
You can also use browser extension to remove X-Content-Type-Options
response header for raw.githubusercontent.com
files. There are couple of browser extensions to modify response headers.
If you use Requestly, I can suggest two solutions
Remove
-> Response
-> X-Content-Type-Options
Url
-> Contains
-> raw.githubusercontent.com
raw.githubusercontent.com
with rawgit.com
Check this screenshot for more details
We created a simple JS Fiddle to test out if we can use raw github files as scripts in our code. Here is the Fiddle with the following code
<center id="msg"></center>
<script src="https://raw.githubusercontent.com/sachinjain024/practicebook/master/web-extensions-master/storage/background.js"></script>
<script>
try {
if (typeof BG.Methods !== 'undefoned') {
document.getElementById('msg').innerHTML = 'Script evaluated successfully!';
}
} catch (e) {
document.getElementById('msg').innerHTML = 'Problem evaluating script';
}
</script>
If you see Script evaluated successfully!
, It means you are able to use raw github file in your code
Otherwise Problem evaluating script
indicates that there is some problem while executing script from raw github source.
I also wrote an article on Requestly blog about this. Please refer it for more details.
Hope it helps!!
Disclaimer: I am author of Requestly So you can blame for anything you don't like.