{"id":15723680,"url":"https://github.com/philnash/jekyll-zopfli","last_synced_at":"2025-06-23T17:07:57.843Z","repository":{"id":56879009,"uuid":"115958361","full_name":"philnash/jekyll-zopfli","owner":"philnash","description":"Generate gzipped assets and files for your Jekyll site at build time using Zopfli compression","archived":false,"fork":false,"pushed_at":"2021-02-13T05:59:17.000Z","size":59,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T11:46:40.206Z","etag":null,"topics":["gzip","jekyll","jekyll-plugin","performance","ruby","ruby-gem","rubygem","webperf","zopfli"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/jekyll-zopfli","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philnash.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"philnash"}},"created_at":"2018-01-02T00:30:01.000Z","updated_at":"2024-05-01T23:47:52.000Z","dependencies_parsed_at":"2022-08-20T22:30:53.797Z","dependency_job_id":null,"html_url":"https://github.com/philnash/jekyll-zopfli","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fjekyll-zopfli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fjekyll-zopfli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fjekyll-zopfli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fjekyll-zopfli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philnash","download_url":"https://codeload.github.com/philnash/jekyll-zopfli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Fjekyll-zopfli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259230541,"owners_count":22825409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gzip","jekyll","jekyll-plugin","performance","ruby","ruby-gem","rubygem","webperf","zopfli"],"created_at":"2024-10-03T22:12:47.442Z","updated_at":"2025-06-11T08:35:15.960Z","avatar_url":"https://github.com/philnash.png","language":"Ruby","funding_links":["https://github.com/sponsors/philnash"],"categories":[],"sub_categories":[],"readme":"# Jekyll::Zopfli\n\nGenerate gzipped assets and files for your Jekyll site at build time using [Zopfli](https://github.com/google/zopfli) compression.\n\n[![Gem Version](https://badge.fury.io/rb/jekyll-zopfli.svg)](https://rubygems.org/gems/jekyll-zopfli) [![Build status](https://github.com/philnash/jekyll-zopfli/workflows/tests/badge.svg)](https://github.com/philnash/jekyll-zopfli/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/177f76759bc3b996e9e2/maintainability)](https://codeclimate.com/github/philnash/jekyll-zopfli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-zopfli.svg?branch=main)](https://inch-ci.org/github/philnash/jekyll-zopfli)\n\n[API docs](http://www.rubydoc.info/gems/jekyll-zopfli/) | [GitHub repo](https://github.com/philnash/jekyll-zopfli)\n\n## Why?\n\nPerformance 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 you're making your webserver do it?\n\nWhy not just generate those gzip files at build time? And with Google's Zopfli algorithm, which generates files that are 3-8% smaller than Zlib's maximum compression?\n\n`Jekyll::Zopfli` does just that. Add the gem to your Jekyll application and when you build your site it will generate gzip files for all text based files (HTML, CSS, JavaScript, etc).\n\n### Warning\n\nZopfli is a much slower algorithm than Zlib, so this will likely significantly slow down your site build. If you still want to generate gzip files at build time with a faster build time and Zlib's compression level, check out [`Jekyll::Gzip`](https://github.com/philnash/jekyll-gzip).\n\n### Want even more compression?\n\nZopfli is about the best compression we can get out of the gzip format, but there's more! [Brotli](https://en.wikipedia.org/wiki/Brotli) is a relatively new compression format that is now [supported by many browsers](https://caniuse.com/#search=brotli) and can produce even smaller files. You can use brotli compression alongside gzip in your Sinatra app with [`Jekyll::Brotli`](http://github.com/philnash/jekyll-brotli).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :jekyll_plugins do\n  gem 'jekyll-zopfli'\nend\n```\n\nAnd then execute:\n\n```\nbundle install\n```\n\nThen add the plugin to the `plugins` key in your `_config.yml`\n\n```yml\nplugins:\n  - jekyll-zopfli\n```\n\n## Usage\n\nOnce you have the gem installed, build your Jekyll site in production mode. On Mac/Linux you can run\n\n```bash\nJEKYLL_ENV=production bundle exec jekyll build\n```\n\nOn Windows, set the `JEKYLL_ENV` environment variable to `\"production\"`. Check out [this blog post on setting environment variables on Windows](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html). Then run:\n\n```bash\nbundle exec jekyll build\n```\n\nIn your destination directory (`_site` by default) you will find gzipped versions of all your text files.\n\n`Jekyll::Zopfli` only runs when the environment variable `JEKYLL_ENV` is set to `production` as dealing with gzipping files is unnecessary in development mode and just slows down the site build.\n\n### Configuration\n\n#### Extensions\n\nBy default, `Jekyll::Zopfli` will compress all files with the following extensions:\n\n- '.html'\n- '.css'\n- '.js'\n- '.json'\n- '.txt'\n- '.ttf'\n- '.atom'\n- '.stl'\n- '.xml'\n- '.svg'\n- '.eot'\n\nYou can supply your own extensions by adding a `zopfli` key to your site's `_config.yml` listing the extensions that you want to compress. For example to only compress HTML, CSS and JavaScript files, add the following to `_config.yml`:\n\n```yml\nzopfli:\n  extensions:\n    - '.html'\n    - '.css'\n    - '.js\n```\n\n#### Replacing the original file\n\nIf you host your Jekyll site on AWS S3 you can take advantage of `Jekyll::Zopfli` for compressing the whole site. The only difference is that you need to replace the uncompressed file with the gzipped file (that is, without a `.gz` extension). To enable this in `Jekyll::Zopfli` turn the `replace_files` setting to `true`.\n\n```yml\nzopfli:\n  replace_files: true\n```\n\n### Serving pre-compiled gzip files\n\nYou will likely need to adjust your web server config to serve these precomputed gzip files. See below for common server configurations:\n\n#### nginx\n\nFor nginx, you need to turn on the [`gzip_static` module](http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html). Add the following in the relevant `http`, `server` or `location` block:\n\n```\ngzip_static on;\n```\n\nThe `ngx_http_gzip_static_module` module is not built by default, so you may need to enable using the `--with-http_gzip_static_module` configuration parameter.\n\n#### Apache\n\nIn either a `\u003cDirectory\u003e` section in your Apache config or in an `.htaccess` file, add the following:\n\n```\nAddEncoding gzip .gz\nRewriteCond %{HTTP:Accept-encoding} gzip\nRewriteCond %{REQUEST_FILENAME}.gz -f\nRewriteRule ^(.*)$ $1.gz [QSA,L]\n```\n\n#### Other web servers\n\nTODO: instructions for other web servers like HAProxy, h2o etc.\n\nDo you know how to do this for a different server? Please open a [pull request](https://github.com/philnash/jekyll-zopfli/pulls) or an [issue](https://github.com/philnash/jekyll-zopfli/issues) with the details!\n\n## Development\n\nAfter 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.\n\nTo 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 [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/philnash/jekyll-zopfli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Jekyll::Zopfli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-zopfli/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Fjekyll-zopfli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilnash%2Fjekyll-zopfli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Fjekyll-zopfli/lists"}