Make a CDN file
Make an asset file that will be hosted on a content delivery network (CDN) like jsdelivr.
Goal
- Make a custom version of highlight.js.
- Make a public GitHub repository to upload the resulting
highlight.pack.js
file. - Use it in a HTML page with jsdelivr.
Make custom highlight.js
- Browse to https://highlightjs.org/download.
- Create a custom bundle by selecting the languages you need.
- Click the Download button and save the
highlight.zip
file locally. - Uncompress
highlight.zip
to revealhighlight.pack.js
.
Make a public GitHub repository
- Sign in to your GitHub account.
- Create a new repository named
cdn
orassets-cdn
or any name you prefer. - Optional: create a README file, a LICENSE file, a sub-directory, etc.
- Click the "Upload file" button to upload
highlight.pack.js
.
Use the CDN file in HTML
- Read the usage instructions on jsdelivr in the GitHub CDN section: https://www.jsdelivr.com/features#gh
- The uploaded
highlight.pack.js
will be available through jsdelivr with a HTML<script>
tag.
<script src="https://cdn.jsdelivr.net/gh/{github username}/{repo name}/highlight.pack.js"></script>
Example for Nevvix PWF CDN:
- Load one of the stylesheets from highlight.js.
- Load your new custom CDN script.
- Initialize the highlight.js script.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/tomorrow-night-bright.min.css">
<script src="https://cdn.jsdelivr.net/gh/nevvix/pwf-cdn/highlightjs/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
Make many CDN files
- You can create a website or web application in one repository.
- You can create a public GitHub repository to host your asset files: CSS stylesheets and JavaScript files.
This way, your asset files don't have to bloat your website's version control repository.