惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
M
MIT News - Artificial intelligence
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
L
LangChain Blog
D
Docker
G
Google Developers Blog
B
Blog RSS Feed
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
I
InfoQ
博客园 - 【当耐特】
The Cloudflare Blog
P
Proofpoint News Feed
GbyAI
GbyAI
博客园 - 司徒正美
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Jina AI
Jina AI
量子位
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
大猫的无限游戏
大猫的无限游戏
F
Full Disclosure
雷峰网
雷峰网
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

kkocdko's blog

极限压缩文档扫描件 - kkocdko's blog Bypass the Blank Chars Detection crknob - Chrome portable patch 我如何将博客首页体积降至 3 KB - kkocdko's blog 如何极限优化压缩文件体积 - kkocdko's blog EmEditor 精简版 - kkocdko's blog Backup Data from VSCode Web 优雅地游玩 Minecraft - kkocdko's blog 让程序以管理员权限运行的 PE 清单 - kkocdko's blog 注销 ZEIT 账号之后遇到的坑 - kkocdko's blog 本博客的协议已更改为 CC0 - kkocdko's blog mobp - 使 MSOffice 后台常驻 在安装 VS 生成工具时规避 .NET 安装错误 各种格式的占位空文件 - kkocdko's blog 优雅地游玩 Flash 游戏 - kkocdko's blog WPS 2016 极限精简版 - kkocdko's blog Convert Const to Let by Terser 规避 Visual Studio 许可证过期的 Bug 方便地使用 iPod - kkocdko's blog 用 UserJS 注入 UserCSS - kkocdko's blog 注册表修改文件关联(默认程序) - kkocdko's blog 周期精准的太阳系模型 - kkocdko's blog 关闭屏幕的 WinAPI - kkocdko's blog 重置 Windows 图标缓存 - kkocdko's blog AIDA64 极限精简单文件版 - kkocdko's blog 几何画板单文件精简版 - kkocdko's blog 世界之窗浏览器单文件版 - kkocdko's blog 在 MBR + Legacy 下用 Bootmgr 引导 Ubuntu 简洁的 Markdown 预览工具 - kkocdko's blog 修复 MSOffice 墨迹不可用问题 - kkocdko's blog 使用 VBA 批量转换 Office 文档格式 不便携的有道词典便携版 - kkocdko's blog 关于清华同方还原卡的一个坑 - kkocdko's blog 也许是最简洁的搜狗输入法皮肤 - kkocdko's blog 用批处理弄个 U 盘复制器 - kkocdko's blog 美化版 TRIXX - kkocdko's blog Windows 默认蓝色代码 - kkocdko's blog A4 大小的普通英文稿纸 - kkocdko's blog 在批处理中延时(等待) - kkocdko's blog 让批处理隐藏窗口运行 - kkocdko's blog 让批处理以管理员权限运行 - kkocdko's blog 批量修改 PPT 字体样式 - kkocdko's blog New Post - kkocdko's blog Block Android dex2oat on demand Disable “insecure download blocked” warning on Chrome and Edge Reduce memory usage of FreeCAD and OrcaSlicer 用 GDB + Python 获取 Linux 端微信本地数据库密钥 Android bug prevents exfat readonly USB drive Cons of IronRDP today, compare to FreeRDP Multi call binary for existing projects WPS Android modified and stripped Disadvantages of APE - kkocdko's blog Change Linux UKI cmdline without regeneration Disk duplicator is considered deprecated 请弃用网易邮箱 - kkocdko's blog Summary of window state restore on desktop Draft of Mono Client Project Right path to use new glibc on old Linux Linux 笔电的所谓省电技巧 - kkocdko's blog Android 腾讯 TIM 迁移 QQ 指北 消费级 Android on Windows 是没有前途的 请停止滥用新 Web 标准特性 - kkocdko's blog Rescuing data from offline sites Differences in AMD P-State modes after kernel 6.3 Fix Docker 'input device is not a TTY' elegantly Recording + streaming on Wayland kk 对耳机主动降噪功能的体验与评价 - kkocdko's blog Node.js native addon without node-gyp Standalone and portable MSVC - kkocdko's blog 腾讯云安装 Fedora - kkocdko's blog 优化 Git 仓库的额外提示 - kkocdko's blog Using hwmoncat, a tiny alternative to lm_sensors Build Fedora ISO in 3 Commands 简陋的 Win on Linux 兼容方案 Tradition and Modernity in Async Rust Change ZSTD Level in QCOW2 无损转换 PDF 到 Word 是不可能的 Dump PDF from HEP Website Fedora for Termux - kkocdko's blog Using VSCode Web Server Variant Tricks for C++ Simple App Development Tweak CPU Power Elegantly on Windows Fix Windows Power Options Ineffective 优雅地使用联想电脑管家 - kkocdko's blog Restone Image's Alpha Channel - kkocdko's blog 成立 hal-drv 组织,维护一些 Rust embedded-hal 外设驱动 PotPlayer 图标包:爱奇艺播放器 - kkocdko's blog 爱奇艺万能播放器调教指南 - kkocdko's blog Draft - kkocdko's blog
在 2023 年评测前端静态资源公共 CDN - kkocdko's blog
2026-04-11 · via kkocdko's blog

还记得我才接触前端时(啊,那时我还很年轻——)hhhhh 不多说了,总之当下前端工程化后,大家都把东西塞进 Bundle 了,曾经很重要的“前端静态资源公共 CDN”也似乎即将成为时代的眼泪。然而对于一些写 Demo 之类的需求,它们还是有点用的,再加上目前互联网上对静态资源公共 CDN 的评测文章大多过时,于是我测试并总结了一下。本次测试使用 curl 和 hyperfine 并切换多个代理节点(是的我知道这不精确)。

TLDR: 境外 jsDelivr / UNPKG 任选,境内推荐 npmmirror,境内外都有需求建议 npmmirror 但不完美。如使用特别流行的库,也可使用 cdnjs 或其他国内 CDN。

前端公共 CDN 目前大致分两类,一类是 cdnjs 这种需提交审核的,另一类是 jsDelivr 这种镜像 NPM 的。前一类的代表自然是 Cloudflare cdnjs,或者 Google 的 CDN。国内此类 CDN 通常以 cdnjs 为上游进行同步。BootCDN 曾经很流行,但曾有多次事故,恐怕用起来还需谨慎。

后一类是本文重点,许多时候我们写的 Demo 所需的库并未被 cdnjs 收录,提交审核又太费时费力,所以我偏好使用直接镜像 NPM 的公共 CDN

分别是 npmmirror(淘宝 NPM 镜像),饿了么 UNPKG CDN,UNPKG,jsDelivr。我们的测试命令:

testonce(){ ./hyperfine -w 2 -r 10 -p "sleep 1" -u millisecond "curl $1 >/dev/null" ;}
testonce https://registry.npmmirror.com/@fontsource/noto-serif-sc/5.0.3/files/files/noto-serif-sc-chinese-simplified-400-normal.woff2
testonce https://npm.elemecdn.com/@fontsource/noto-serif-sc@5.0.3/files/noto-serif-sc-chinese-simplified-400-normal.woff2
testonce https://unpkg.com/@fontsource/noto-serif-sc@5.0.3/files/noto-serif-sc-chinese-simplified-400-normal.woff2
testonce https://cdn.jsdelivr.net/npm/@fontsource/noto-serif-sc@5.0.3/files/noto-serif-sc-chinese-simplified-400-normal.woff2

得到结果:

江苏镇江某大学校园网:

Brandmean ± σ
npmmirror594.9 ms ± 65.4 ms
Eleme CDN627.1 ms ± 74.7 ms
UNPKG3820.7 ms ± 1209.7 ms
jsDelivrTimeout (> 5 s)

江苏镇江移动 4G:

Brandmean ± σ
npmmirror1570.4 ms ± 316.1 ms
Eleme CDN1545.3 ms ± 203.4 ms
UNPKG3514.2 ms ± 1278.3 ms
jsDelivrReset

阿里云 ECS 新加坡:

Brandmean ± σ
npmmirror82.8 ms ± 3.5 ms
Eleme CDN961.7 ms ± 79.7 ms
UNPKG79.5 ms ± 12.2 ms
jsDelivr73.6 ms ± 26.7 ms

Azure 日本(机场全局,不精确):

Brandmean ± σ
npmmirror985.8 ms ± 92.9 ms
Eleme CDN5897.9 ms ± 1085.7 ms
UNPKG901.6 ms ± 59.5 ms
jsDelivr876.6 ms ± 24.7 ms

Azure 美国(机场全局,不精确):

Brandmean ± σ
npmmirror2331.3 ms ± 190.0 ms
Eleme CDNTimeout (> 5 s)
UNPKG2144.2 ms ± 92.8 ms ms
jsDelivr2496.5 ms ± 116.4 ms

总结:jsDelivr 曾经是完美的选择,但自从证书吊销事件后在大陆地区的访问就不是很正常;UNPKG 表现一般,至少都能用;npmmirror 在境外也有节点,虽然不如 jsDelivr 那么多,但是均衡的选择;饿了么 CDN 仅适合无境外访问需求的场景。