Using NPM as a CDN

Scenario

We just published @fireflysemantics/fs-gist .

We want to use NPM as a CDN such that we can declare fs-gist in a script tag.

Approach

We will use UNPKG:

We simply declare our script tag like this:

<script src="https://unpkg.com/@fireflysemantics/fs-gist"></script>

Generally the format for the domain, host, and fragment parts of the URL is:

unpkg.com/:package@:version/:file

In our case we did not specify version and we left out the file, since we will be using what is specified in the main attribute of package.json.

Related Concepts

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation