How To Fix MIME Type Error When Linking To Github Resource

By: Yusuf Odukoya /
 September 15, 2021
  / < 1 minute
Categories: Coding

The MIME type error can happen when you attempt to hotlink a JavaScript file hosted on GitHub in your <script src=""> tag. GitHub has explicitly disabled JavaScript hotlinking, and newer versions of browsers respect that setting.

In the year 2013, GitHub started using X-Content-Type-Options: nosniff, which instructs modern browsers to enforce strict MIME type checking. For browsers that honour this setting, they would be unable to parse or process the file as intended, instead, they return the raw files as is.

In other words, you’ll find an error in your console, similar to what is shown below;

Refused to execute as script because "X-Content-Type-Options: nosniff" was given and its Content-Type is not a script MIME type.

To permanently solve this problem, follow the jsdelivr CDN workaround below;


  1. Find the file you are linking to on GitHub, and click to the “Raw” version.
  2. Copy the URL.
  3. Replace with
  4. Add /gh/ just before your username.
  5. Remove the branch name.

Here is an illustration;


<script src="<username>/<repo>/<branch>/path/to/file.js">

to 👇🏽

<script src="<username>/<repo>/path/to/file.js">

I hope that helps.

You May Also Like: Free Static Website Hosting With Wordpress, Namecheap, & Github Pages


Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Related Posts 👇🏽

Leave a Comment

Share via
Copy link
Powered by Social Snap