Generate brotli compressed assets and files for your Jekyll site at build time
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Generate compressed assets and files for your Jekyll site at build time using Brotli compression.

Gem Version Build Status Maintainability Inline docs

API docs | GitHub repo


Performance in web applications is important. You know that, which is why you have created a static site using Jekyll. But you want a bit more performance. You're serving your assets and files gzipped, but could it be better?

Google's Brotli compressor is a new format with better compression than Zlib's gzip or Zopfli and is supported in all major modern browsers. Compressing files at build time means you can use the highest compression levels with no penalty for dynamically generating the files, so if you're building your site with Jekyll, why not generate the files at the same time?

Jekyll::Brotli does just that. Add the gem to your Jekyll application and when you build your site it will generate brotli files for all text based files (HTML, CSS, JavaScript, etc).


Brotli is not supported everywhere, so you may want to also gzip your files too. Check out Jekyll::Gzip and Jekyll::Zopfli for options there.


Add this line to your application's Gemfile:

gem 'jekyll-brotli'

And then execute:

bundle install


Once you have the gem installed, run JEKYLL_ENV=production bundle exec jekyll build. In your destination directory (_site by default) you will find brotli files.

Jekyll::Brotli only runs when the environment variable JEKYLL_ENV is set to production as dealing with compressing files is unnecessary in development mode and just slows down the site build.

Serving pre-compiled gzip files

You will likely need to adjust your web server config to serve these precomputed gzip files. See below for common server configurations:


For nginx, you need to compile nginx with Google's ngx_brotli module. Follow the steps in this blog post for more detail.

Other web servers

TODO: instructions for other web servers like Apache, HAProxy, etc.

Do you know how to do this for a different server? Please open a pull request or an issue with the details!


After checking out the repo, run bundle install to install dependencies. Then, run bundle exec rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Jekyll::Brotli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.