Is there are way to import a js module hosted on github?

Hi there,

I got a js module hosted on a repo, I try to import it in my project like so :

import "https://raw.githubusercontent.com/solidsnail/reponame/master/path/to/index.js"

But apparently github returns the file as a raw text ( Content-Type: text/plain ), I want it to return text/javascript instead, is this somehow possible ? Because I would love to host my modules on github instead of cdn services.

Thanks in advance

GitHub doesn’t offer a way to do this right now. Services like unpkg do this for npm packages and there are other services that do this as well but not official GitHub services.

2 Likes

Any plans on supporting this in the future or is this out of the scope of Github goals ?

We’re interested in doing this to support Deno and other use cases but the timeline is unclear.

1 Like

Using GitHub Pages appears to be a popular workaround, see:

1 Like

Works perfectly ! Thanks y’all