Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load JavaScript files from GitHub externally? [duplicate]

How can I load a JavaScript file from raw.github.com? This code for CSS works perfectly well: <link rel="stylesheet" type="text/css" href="https://raw.github.com/myusername/myrepo/master/style.css">

But it will not work for JavaScript: <script src="https://raw.github.com/myusername/myrepo/master/script.js"></script>

like image 462
Ptr13 Avatar asked Oct 10 '13 01:10

Ptr13


1 Answers

You cannot load JavaScript from Github because the content type is not application/javascript or text/javascript.

This is done intentionally to prevent you from using Github as a CDN, which is in violation of their terms of service.

See also: https://rawgithub.com/

And this: https://github.com/blog/1482-heads-up-nosniff-header-support-coming-to-chrome-and-firefox

like image 161
Brad Avatar answered Sep 28 '22 09:09

Brad