想要玩一下jquery-mockjax,其原始文件为https://raw.githubusercontent.com/jakerella/jquery-mockjax/master/dist/jquery.mockjax.js ,加入我的html文件进行测试。结果却遇到下列问题:
Refused to execute script from ... because its MIME type (text/plain) is not executable, and strict MIME type checking is enabled.
查到了StackOverflow上的一个帖子Link and execute external JavaScript file hosted on GitHub ,原来GitHub开始使用X-Content-Type-Options:nosniff
以令更多的现代浏览器执行严格MIME类型检查,之后返回原始文件的MIME类型故意让浏览器不能使用。帖子中提到的临时解决方法是将raw.githubusercontent.com替换为rawgit.com。我将上一链接替换成https://rawgit.com/jakerella/jquery-mockjax/master/dist/jquery.mockjax.js ,解决问题!