Skip to content
KD
Go back

Getting a CDN Link for Every File on GitHub

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.js

Now prepend the jsDelivr base URL:

https://cdn.jsdelivr.net/gh/{username}/{reponame}/path/to/file/script.js

That’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.


Share this post on:

Previous Post
Nano Editor Keyboard Shortcuts — Complete Reference