Char
Char15mo ago

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
ioB
ioB15mo ago
No, code can be imported from any link on the internet!
Char
Char15mo ago
so i could import from this? https://github.com/USER/REPO/blob/main/index.js
ioB
ioB15mo ago
you'd have to use the raw github link since github by default serves the content as HTML
Char
Char15mo ago
ah right, thank you!
ioB
ioB15mo ago
so: https://raw.githubusercontent.com/USER/REP/main/index.js
NDH
NDH15mo ago
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.
jeff.hykin
jeff.hykin14mo ago
you can also link to a specific commit if you want to make sure it's a pinned version of the Github import
https://raw.githubusercontent.com/USER/REP/COMMIT_HASH/index.js`
https://raw.githubusercontent.com/USER/REP/COMMIT_HASH/index.js`
Mark G
Mark G14mo ago
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=gh
jsDelivr
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.