hexo压缩

hexo 压缩

为了提高 Hexo 博客的加载速度,可以使用插件对静态资源进行压缩。以下是使用 hexo-neat 插件进行压缩的步骤。

安装和配置

首先,在站点根目录下安装 hexo-neat 插件:

1
npm install hexo-neat --save

然后,在站点配置文件 _config.yml 中添加以下配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# hexo-neat
neat_enable: true
neat_html:
enable: true
exclude:
neat_css:
enable: true
exclude:
- '**/*.min.css'
neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '**/*.min.js'
- '**/jquery.fancybox.pack.js'
- '**/index.js'

注意事项

跳过特定文件:确保在配置中正确指定要跳过的文件路径,否则可能无法生效。

不要跳过 .md 和 .swig 文件:跳过这些文件可能会导致页面生成错误或压缩效果不佳。

通过以上步骤,您可以有效地压缩 Hexo 博客的静态资源,从而提升页面加载速度和用户体验。如果需要更高级的压缩选项,可以考虑使用 hexo-all-minifier 插件。

了解详细信息:
1 -
blog.csdn.net
2 -
cloud.tencent.com
3 -
blog.csdn.net