Open Source CDN “jsDelivr”: Learn to host your repository JS/CSS

We will learn about CDN service which uses Github as CDN. Most developers use Github as their code repository, keeping all their UI assets like fonts , js , css , images etc.

CDN delivery service called "jsDelivr" is a free CDN for open source projects.

Open Source CDN jsDelivr

Here’s how it works.

jsDelivr CDN service’s base URL is https://cdn.jsdelivr.net/gh/{username}/{repo}/
  • Replace {username} with the GitHub username
  • Replace {repo} with the GitHub repository name for the project.
Like in case of Brighten Minds project this is how url will look like:
https://cdn.jsdelivr.net/gh/geekjai/brightenminds

Now at the end append above URL with the path to the file you want to access in the project.

For example in brightenminds repository, file 'theme-alpha.js' is located in the bm-themes directory, so final url will like below:
https://cdn.jsdelivr.net/gh/geekjai/brightenminds/bm-themes/theme-alpha.js

Semantic versioning is also available. You can use it by adding @{version-number} to the repository name. You can target major, minor, and patch releases as desired.

Load the latest version

<script src='https://cdn.jsdelivr.net/gh/geekjai/brightenminds/bm-themes/theme-alpha.js'></script>

Load with Major Version only

<script src='https://cdn.jsdelivr.net/gh/geekjai/brightenminds@2/bm-themes/theme-alpha.js'></script>

Load with Major Version only

<script src='https://cdn.jsdelivr.net/gh/geekjai/brightenminds@2/bm-themes/theme-alpha.js'></script>

Load with Major.Minor Version

<script src='https://cdn.jsdelivr.net/gh/geekjai/brightenminds@2.1/bm-themes/theme-alpha.js'></script>

Load Exact version

<script src='https://cdn.jsdelivr.net/gh/geekjai/brightenminds@0.0.8/bm-themes/theme-alpha.js'></script>

Load minified version

Add “.min” to any JS/CSS file to get a minified version — if one doesn’t exist, it will be automatically generated for you.