Getting a CDN Link for Every File on GitHub
Learn how to convert any GitHub file URL into a blazing-fast CDN link using jsDelivr — no docs required.
Sometimes you want to load a file into your web project via a CDN, but the library’s docs don’t provide a CDN link. Here’s a quick solution.
Using jsDelivr#
There’s an easy fix using a service called jsDelivr. Navigate to the project’s GitHub page and locate the file you want to use.
Copy the URL shown in your browser. Then remove everything up to and including /blob/main. You’ll be left with a path like:
/path/to/file/script.jsNow prepend the jsDelivr base URL:
https://cdn.jsdelivr.net/gh/{username}/{reponame}/path/to/file/script.jsThat’s it — you now have a blazing-fast CDN link for any file on GitHub.
An Even Easier Solution#
jsDelivr provides a dedicated conversion tool on their website: jsdelivr.com/github
Just paste your GitHub URL and it automatically outputs the CDN link. No manual editing required.