0.2.2 • Published 3 months ago

hexo-lightning-minify v0.2.2

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
3 months ago

hexo-lightning-minify

Introduction

This plugin is a modular minifier extracted from hexo-renderer-multi-next-markdown-it. Refactored with modern minification tools (e.g., lightningcss), it achieves significant performance improvements compared to legacy implementations.

For comprehensive optimization solutions, consider using hexo-optimize. This project primarily serves as a companion package for ShokaX, focusing on essential minification and optimization functionalities.

Installation

pnpm add hexo-lightning-minify # Recommended with pnpm
npm install hexo-lightning-minify

Configuration

minify:
  js:
    enable: true # Not recommended for ShokaX (built-in esbuild optimization). Enable for other themes.
    exclude: # Excluded files (string[] compatible with micromatch patterns)
  css:
    enable: true # Enable CSS optimization
    options:
      targets: ">= 0.5%" # Browser targets in browserslist format
    exclude: # Excluded files (string[] compatible with micromatch patterns)
  image:
    enable: true # Enable image preprocessing and automatic WebP conversion
    options:
      # Format selection
      avif: true
      webp: false
      quality: 60 # Image quality (1-100 integer, lossless, or nearLossless)
      effort: 2 # CPU workload (0-6 integer, lower values prioritize speed)
      replaceSrc: true # Automatically replace local image URLs in HTML with optimized versions
      # Note: Service Worker implementation is recommended for less intrusive URL replacement
      enableSubSampling: true # Enable advanced chroma subsampling
      # For AVIF: Enables 4:2:0 subsampling (4:4:4 when disabled), optimizing size with minimal quality loss
      # For WebP: Allows extended CPU processing time for enhanced quality
      destroyOldRoute: false # Generate only processed images (preserve original assets)
      persistCache: true # Enable persistent caching of processed images
      # Stores optimized images on disk to accelerate subsequent builds
    exclude: # Excluded files (string[] compatible with micromatch patterns)

Features

  • Automatic minification for JS, CSS, and HTML
  • Automatic CSS prefix compatibility handling based on browser targets
  • Automatic AVIF conversion and image preprocessing
  • Preconnect optimization (long-term roadmap)

Benchmark

Note: Initial benchmark tests included HTML compression which has since been deprecated. Current results may vary.

Performance metrics from ShokaX v0.3.9: \

Testing framework using hexo-many-posts:

Environment: Hexo 6.3.0, minification limited to HTML/CSS/JS

basehexo-neathexo-minifyhexo-all-minifierhexo-lightning-minify
landscape10.529s37.918s36.844s38.572s16.304s
next27.275s36.124s42.854s37.063s29.880s
butterfly13.853s26.641s26.736s35.973s16.796s
particlex24.422s200.641s193.981s201.601s40.478s
reimu17.631s52.432s48.524s51.835s23.938s
shokax(hexo-renderer-marked)13.189s20.618s19.658s22.448s14.619s

chart

basehexo-neathexo-minifyhexo-all-minifierhexo-lightning-minify
landscape99,617,529B97,186,156B92,010,232B97,184,707B88,175,339B
next32,469,157B30,087,003B28,744,583B30,059,443B28,020,740B
butterfly37,593,633B37,237,074B33,485,597B34,897,171B35,504,670B
particlex540,876,348B226,997,833B214,050,994B226,990,791B221,896,130B
reimu110,252,086B95,756,049B91,074,639B95,715,486B88,088,009B
shokax(hexo-renderer-marked)142,585,026B142,404,138B140,988,094B142,011,849B140,457,331B

hexo-theme-particlex excluded from visualization for clearer comparison

chart2

0.2.1

3 months ago

0.2.0

3 months ago

0.2.2

3 months ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago