18

如何从 raw.github.com 加载 JavaScript 文件?这段 CSS 代码运行良好: <link rel="stylesheet" type="text/css" href="https://raw.github.com/myusername/myrepo/master/style.css">

但它不适用于 JavaScript: <script src="https://raw.github.com/myusername/myrepo/master/script.js"></script>

4

1 回答 1

24

您无法从 Github 加载 JavaScript,因为内容类型不是application/javascripttext/javascript

这样做是为了防止您将 Github 用作 CDN,这违反了他们的服务条款。

另见: https ://rawgithub.com/

而这个: https ://github.com/blog/1482-heads-up-nosniff-header-support-coming-to-chrome-and-firefox

于 2013-10-10T01:43:45.307 回答