Linking to external code
if i want to link to external code, do i have to import it from https://deno.land?
Deno
Deno — A modern runtime for JavaScript and TypeScript
Deno is a simple, modern runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
8 Replies
No, code can be imported from any link on the internet!
so i could import from this?
https://github.com/USER/REPO/blob/main/index.js
you'd have to use the raw github link
since github by default serves the content as HTML
ah right, thank you!
so:
https://raw.githubusercontent.com/USER/REP/main/index.js
On githug, go to the file you want.
In the upper right, click the 'raw' button.
You can then copy the URL from the browsers address bar.
You can then copy the URL from the browsers address bar.
you can also link to a specific commit if you want to make sure it's a pinned version of the Github import
There are also some services that provide nicer URLs for github content, that follow the
.../name@version/...
convention, eg: https://ghuc.cc/, https://www.jsdelivr.com/?docs=ghjsDelivr
jsDelivr - A free, fast, and reliable CDN for JS and Open Source
Optimized for JS and ESM delivery from npm and GitHub. Works with all web formats. Serving more than 150 billion requests per month.