Skip to content
A Jekyll plugin that uses uncss to remove unused css rules.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
uncss.rb
uncss_wrapper.rb

README.md

jekyll-uncss

A Jekyll plugin that uses uncss to remove unused css rules in selected stylesheets.

Setup

cd YOUR_JEKYLL_DIR/_plugins && git submodule add https://github.com/episource/jekyll-uncss.git

This plugin depends on uncss. See uncss for installation instructions.

Configure

Configure uncss by adding a uncss node to your _config.yml. The stylesheets option is mandatory, all others are optional. By default all html files (**/*.html) are considered. Use the files option to change this.

For most option there's a corresponding uncss option and the configuration is just passed through (maybe with some path adjustments). A noticable exception is the stylesheets option: Instead of passing all css files to uncss at once (which would result in the stylesheets being merged), the css files are passed one by one. So each file given is processed separately.

uncss:
  stylesheets:            # a list of stylesheets to be processed; mandatory
    - assets/css/main.css
  files:                  # html files to consider, globs are supported; default: **/*.html
    - "**/*.html"
    - "**/*.htm"
  compress: true          # compress resulting css with sass; default: false
  ignore:                 # always keep rules for these selectors; default: none
    - ".is-loading"
    - "#titleBar"
  media:                  # additional media queries to consider; default: undefined
    - print
  timeout: 30             # how long to wait for the JS to be loaded; default: undefined

Note: The ignore option can also be included as a css comment. See uncss documentation for details.

You can’t perform that action at this time.