Go to file
weyusi 1ea89ec108 chore: disable package-lock.json 2019-04-12 14:44:25 +09:30
lib feat: switch to terser for ES6 compatibility 2019-04-10 19:24:02 +09:30
.gitignore Remove package-lock.json 2018-10-26 13:16:08 +10:30
.npmignore Update formatting 2018-09-27 16:31:14 +09:30
.npmrc chore: disable package-lock.json 2019-04-12 14:44:25 +09:30
.snyk Update snyk policy 2018-09-30 18:01:01 +09:30
.travis.yml test: update package.json to snyk in every build 2018-10-30 18:37:10 +10:30
README.md docs: replace uglifyjs with terser 2019-04-10 19:34:43 +09:30
index.js refactor: remove object-assign ponyfill 2018-10-27 18:38:12 +10:30
package.json release: v1.2.0 2019-04-10 19:35:15 +09:30

README.md

Hexo-yam

npm version Build Status NPM Dependencies Known Vulnerabilities Greenkeeper badge

This project is based on hexo-neat

Yet Another Minifier for Hexo. Minify and compress html, js and css. xml and json are compressed only. Support gzip and brotli compressions.

The original package has not been updated for a while. I update the dependencies and add compression support.

All the options are the same, so you can use this as a drop-in replacement.

Note: See HTTP Compression section below for more info on using brotli.

Installation

$ npm install hexo-yam --save

Usage

To enable this plugin, insert the following to _config.yml:

neat_enable: true

For further customization, see below.

Options

neat_html:
  enable: true
  exclude:
  • enable - Enable the plugin. Defaults to true.
  • logger - Verbose output. Defaults to false.
  • exclude - Exclude files

For more options, see HTMLMinifier.


neat_css:
  enable: true
  exclude:
    - '*.min.css'
  • enable - Enable the plugin. Defaults to true.
  • logger - Verbose output. Defaults to false.
  • exclude - Exclude files

neat_js:
  enable: true
  exclude:
    - '*.min.js'
  • enable - Enable the plugin. Defaults to true.
  • mangle - Mangle file names. Defaults to true.
  • logger - Verbose output. Defaults to false.
  • output - Output options
  • compress - Compress options
  • exclude - Exclude files

For more options, see UglifyJS.


neat_gzip:
  enable: true
  • enable - Enable the plugin. Defaults to true.
  • logger - Verbose output. Defaults to false.

neat_brotli:
  enable: true
  • enable - Enable the plugin. Defaults to true.
  • logger - Verbose output. Defaults to false.

HTTP Compression

While most modern web browsers support Brotli, you also need to consider whether the web/app server, hosting platform, reverse proxy or CDN (whichever relevant to you) support it.

As of 2018, GitHub/GitLab Pages and Netlify do not support brotli. You can generate .br files, but they won't be serving those files.

If you have access to the web server config, you should disable on-the-fly compression for static files (that are already compressed by this plugin), e.g.

  • nginx: Make sure both filter and static modules are enabled. This way pre-compressed .br files will be served while dynamic content can be compressed on-the-fly. Protip: brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss; to prevent compressing media files (which are already compressed anyway).
  • Apache: See 'Serving pre-compressed content' section of mod_brotli.
  • Caddy: 0.9.4+ by default support pre-compressed .gz .br files and on-the-fly gzip compress dynamic files.
  • express/connect: Use pre-compressed-assets. You still can continue to use compression/shrink-ray-current for dynamic files.

Credits

All credits go to the following work: