8.0.0 • Published 1 year ago

hexo-yam v8.0.0

Weekly downloads
60
License
MIT
Repository
github
Last release
1 year ago

hexo-yam

npm version Build Status NPM Dependencies Known Vulnerabilities Greenkeeper badge

Yet Another Minifier for Hexo. Minify and compress HTML, JS, CSS and SVG. XML, JSON and many more are also compressed. Support gzip and brotli compressions.

Version 3

In v3 onwards, this plugin is enabled by default. Most options have changed and they are now under minify: option.

Example:

neat_svg:
  plugins: [{cleanupIDs: false}]

needs to be updated to

minify:
  svg:
    plugins: [{cleanupIDs: false}]

Installation

$ npm install hexo-yam --save

Options

minify:
  enable: true
  • enable - Enable the plugin. Defaults to true.

minify:
  html:
    enable: true
    exclude:
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10. Set lower value to set higher priority and vice versa.
  • logger - Verbose output. Defaults to false.
  • exclude - Exclude files.
    • Support one-liner, exclude: [*.min.html, *.note.html].
    • To exclude a file, double asterisk and the full path must be specified, **/themes/typing/source/js/source.js.
    • *source.js also works, but it also excludes resource.js.
    • Test glob pattern on the web using Globtester.
  • globOptions - micromatch options to customise how glob patterns match files. Defaults to { basename: true }, unless the pattern has a slash.

For more options, see HTMLMinifier.


minify:
  css:
    enable: true
    exclude:
      - '*.min.css'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • logger - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern.
  • level - Optimization level. Defaults to 2.
  • globOptions - See html:.

For more options, see clean-css.


minify:
  js:
    enable: true
    exclude:
      - '*.min.js'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • logger - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern.
  • compress - Compress options.
  • mangle - Mangle variable names. Defaults to true. Pass an object to specify mangle options.
  • output - Output options.
    • To retain comments, output: {comments: true}.
  • globOptions - See html:.

For more options, see Terser.


minify:
  svg:
    enable: true
    include:
      - '*.svg'
      - '!*.min.svg'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • logger - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern.
    • Exclude *.min.svg by default.
  • plugins - Plugin options.
    • To retain comments, plugins: [{removeComments: false}].
  • globOptions - See html:.

For more options, see svgo.


minify:
  gzip:
    enable: true
    include:
      - '*.html'
      - '*.css'
      - '*.js'
      - '*.txt'
      - '*.ttf'
      - '*.atom'
      - '*.stl'
      - '*.xml'
      - '*.svg'
      - '*.eot'
      - '*.json'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • logger - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern.
    • Support one-liner, include: ['*.html','*.css','*.js'].
    • Must include asterisk and single quotes. .html is invalid. '*.html' is valid.
  • globOptions - See html:.

minify:
  brotli:
    enable: true
    include:
      - '*.html'
      - '*.css'
      - '*.js'
      - '*.txt'
      - '*.ttf'
      - '*.atom'
      - '*.stl'
      - '*.xml'
      - '*.svg'
      - '*.eot'
      - '*.json'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • logger - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern.
  • globOptions - See html:.

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 May 2019, GitHub Pages, GitLab Pages and Netlify do not support brotli yet. You can generate .br files, but they won't serve those files.

NameStatus (May 8, 2019)
GitHub PagesIn consideration
GitLab PagesIn progress
NetlifyIn consideration

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),

  • 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:

8.0.0

1 year ago

7.0.0

2 years ago

6.0.0

3 years ago

5.0.0

3 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.2.3

4 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago