Skip to content

Instantly share code, notes, and snippets.

@sajith-rahim
Last active December 29, 2022 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajith-rahim/6c11a3fd9ff90279d863c80e251e23fa to your computer and use it in GitHub Desktop.
Save sajith-rahim/6c11a3fd9ff90279d863c80e251e23fa to your computer and use it in GitHub Desktop.
Using / Hosting and distributing js files in Github via jsDelivr

Hosting and serving js files in Github via jsDelivr

Use jsDelivr Github Tool

Manual Steps

  1. Open the raw version of your file in Github and copy the url

url should look something like this
https://raw.githubusercontent.com/<user-name>/<repo-name>/<branch>/<path_to_file>/filename.js

  1. Replace raw.githubusercontent.com to cdn.jsdelivr.net

https://cdn.jsdelivr.net/<user-name>/<repo-name>/<branch>/<path_to_file>/filename.js

  1. Remove the branch name.

https://cdn.jsdelivr.net/<user-name>/<repo-name>/<path_to_file>/filename.js

  1. Insert gh/ before your username.

https://cdn.jsdelivr.net/gh/<user-name>/gh/<repo-name>/<path_to_file>/filename.js

Serving a specific commit

https://cdn.jsdelivr.net/gh/<user-name>/gh/<repo-name>@<commit_hash>/<path_to_file>/filename.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment