美文网首页Hexo
加速 Hexo 博客

加速 Hexo 博客

作者: reuixiy | 来源:发表于2018-05-30 14:39 被阅读217次

利用 hexo-service-worker 和 hexo-filter-optimize 让博客快如闪电 ⚡

先体验:https://yixiuer.github.io/ ,然后操作 :dolphin: ~

主要利用两个插件:

  1. hexo-service-worker
  2. hexo-filter-optimize

先在站点文件夹根目录安装:

npm install hexo-service-worker hexo-filter-optimize --save

然后在站点配置文件中配置:

# offline config passed to sw-precache.
service_worker:
  maximumFileSizeToCacheInBytes: 5242880
  staticFileGlobs:
  - public/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2}
  stripPrefix: public
  verbose: true

filter_optimize:
  enable: true
  # remove static resource query string
  #   - like `?v=1.0.0`
  remove_query_string: true
  # remove the surrounding comments in each of the bundled files
  remove_comments: true
  css:
    enable: true
    # bundle loaded css file into the one
    bundle: true
    # use a script block to load css elements dynamically
    delivery: true
    # make specific css content inline into the html page
    #   - only support the full path
    #   - default is ['css/main.css']
    inlines:
    excludes:
  js:
    # bundle loaded js file into the one
    bundle: true
    excludes:
  # set the priority of this plugin,
  # lower means it will be executed first, default is 10
  priority: 12

最后 deploy 到 Github 上查看效果,Enjoy it ! :coffee: ~


原文地址:https://reuixiy.github.io/technology/computer/computer-aided-art/2018/05/30/speed-up-hexo.html

相关文章

网友评论

  • TitanCoder:你好, 我添加插件之后, 博客(NexT主题)所有小图标都变成小方框, 原图标不显示了, 请问遇到过吗
    TitanCoder:@pengloo53 好像也不行, 就是侧边栏的图标不显示了, 都是来源https://fontawesome.com/icons?from=io的图片不显示, 我的博客https://www.titanjun.top/, 你可以去看一下不显示的效果!还望大佬赐教, 谢谢
    lupeng:- public/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2}

    配置中,把图标的后缀名排除掉 svg,eot,ttf,woff,woff2
  • lupeng:站点不错,第一眼看上去很炫

本文标题:加速 Hexo 博客

本文链接:https://www.haomeiwen.com/subject/txntsftx.html