DOCUMENTATION
使用文档
本站兼容 jsDelivr 的路径规则,多数场景只需替换域名即可使用。
快速迁移
将 jsDelivr 链接中的 cdn.jsdelivr.net 替换为本站域名即可:
| 原始 | 替换后 |
|---|---|
https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js | https://fastjsd.com/npm/jquery@3.7.1/dist/jquery.min.js |
其中 fastjsd.com 为本站当前域名。
支持的源与路径格式
| 源 | 本站路径格式 |
|---|---|
| npm | /npm/<pkg>@<ver>/<file> |
| unpkg | /unpkg/<pkg>@<ver>/<file> |
| GitHub | /gh/<user>/<repo>@<ref>/<file> |
| GitHub Raw | /ghp/<user>/<repo>/<ref>/<file> |
| cdnjs | /cdnjs/<lib>/<ver>/<file> 或 /ajax/libs/<lib>/<ver>/<file> |
| WordPress | /wp/plugins/<slug>/<file>、/wp/themes/<slug>/<file> |
| npmmirror | /china/<path> |
| esm.sh | /esm/<spec> |
| Google Fonts | /fonts/css2?family=... |
| Gravatar | /avatar/<hash>?s=200 |
| combine | /combine/<encoded-path>,<encoded-path> |
不确定路径时,可在 资源信息 页粘贴完整上游 URL(jsDelivr / unpkg / cdnjs / GitHub / raw.githubusercontent / bootcdn / googleapis / npmmirror / esm)自动转换并查看元数据。
子资源完整性 (SRI)
强烈建议为引用的资源添加 integrity 属性,浏览器会校验文件哈希,防止内容被篡改。
在 资源信息 页查询资源后,可复制每个文件的 SRI (integrity) 值,例如:
<script src="https://fastjsd.com/npm/jquery@3.7.1/dist/jquery.min.js"
integrity="sha256-..."
crossorigin="anonymous"></script>批量替换脚本
Linux / macOS:
find src/ -type f -exec sed -i 's/cdn\.jsdelivr\.net/fastjsd.com/g' {} +Windows (PowerShell):
Get-ChildItem -Path src -Recurse -File | ForEach-Object {
(Get-Content $_.FullName) -replace 'cdn\.jsdelivr\.net', 'fastjsd.com' | Set-Content $_.FullName
}