前言

我也来水一篇博文吧,最近我也不知道在忙什么(明明就是懒得更新),也感谢 @夜灭博主,让我可以水一篇博文以及再次优化hexo博客,如你所见我的博客在国内访问基本上都能在5秒以内完成这个所有加载。

正文

博客基本情况

优化过的情况

  1. 源站在GitHub Pages上
  2. 使用双解析模式(国内 腾讯云 国外Cloudflare)
  3. 把 hexo 需要的静态js 资源全部缓存到源站,不在走jsdelivr
  4. 图床使用自建数据在backblaze存储桶上,详细的图床解决方案:https://blog.ning.moe/posts/lskypro-backblaze/
  5. 图床使用cf的自定义域名进行双解析和第二点一样。

图.webp

butterfly 静态资源优化

在最新的 butterfly 4.8.1 中加入了自定义cdn 功能,虽然以前也能改那就要一个一个配置文件上改了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CDN:
# The CDN provider of internal scripts (主題內部 js 的 cdn 配置)
# option: local/jsdelivr/unpkg/cdnjs/custom
# Dev version can only choose. ( dev版的主題只能設置為 local )
internal_provider: local

# The CDN provider of third party scripts (第三方 js 的 cdn 配置)
# option: local/jsdelivr/unpkg/cdnjs/custom
# when set it to local, you need to install hexo-butterfly-extjs
third_party_provider: local

# Add version number to url, true or false
version: false

# Custom format
# For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file}
custom_format:
#以下省略

我这里使用了 local的CDN就是把所有资源封装在本地了,你需要执行npm install hexo-butterfly-extjs命令,hexo 三连命令即可hexo cl && hexo generate && hexo server

如果你不喜欢这样的话,可以参考主题官方提供的配置,可以选择如 七牛云 BootCDN Elemecdn 等
但是这个配置其他cdn 我测试的时候偶尔也会丢失一部分静态资源。