CDN like never before
Add:
<script src="https://cdn.jsdelivr.net/gh/rhenryw/cdns@main/src/index.min.js"></script>
between <head>
and </head>
in your html.
Then use like so:
<img cdn="rhenryw/lupine/public/tinyTitle.png lg=1 ref=main">
or
<script cdn="rhenryw/cdns/src/index.min.js lg=0 ref=main sha=7478a1bc5c898948999d6a2b67f68bde476b9e52">
- cdn:
{user}/{repo}/{path} [lg=0|1] [ref=branch|tag] [sha=commit]
- lg: Use
lg=0
for under 25mb and uselg=1
for assets over 25 MB. - ref: branch or tag to resolve the latest commit from (e.g.,
ref=main
). - sha: explicit commit SHA; skips GitHub lookup.
- lg: Use
- Works for
script
,img
, andlink[rel=stylesheet]
(usessrc
orhref
accordingly). - Observes the DOM for dynamically added nodes and
cdn
attribute changes. - Caches commit SHAs per
{user}/{repo}
andref
to reduce API calls. - If the commit cannot be resolved, the element is left unchanged.