Home > Blockchain >  Can you use RAW Github Gists in <link href=""/>?
Can you use RAW Github Gists in <link href=""/>?

Time:12-30

I'm trying to use CSS I saved in Gist, but can't make it work. No error in the console or anything but the file is not being loaded. Can Gist be used in a way I'm trying to use it? I'm debugging on https://localhost.

<link href="https://gist.githubusercontent.com/[link_to_my_file].css" rel="stylesheet" type="text/plain" crossorigin="anonymous" referrerpolicy="no-referrer" />

CodePudding user response:

No, this isn't going to work. GitHub serves most files as plain text (MIME type text/plain) and to prevent attacks browsers require a correct MIME type (in your case, text/css). GitHub doesn't let you customize the MIME type for this and they really don't want you using the raw file endpoints as your own private CDN.

If you want to use the CSS from your Gist in a website, clone the repository or create an archive and copy the file into your repository when building the website.

  • Related