All Projects → philnash → jekyll-gzip

philnash / jekyll-gzip

Licence: MIT license
Generate gzipped assets and files for your Jekyll site at build time

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to jekyll-gzip

glimmer-dsl-swt
Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
Stars: ✭ 53 (+55.88%)
Mutual labels:  ruby-gem, rubygem
jekyll-target-blank
Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
Stars: ✭ 86 (+152.94%)
Mutual labels:  jekyll-plugin, rubygem
Matestack Ui Core
Matestack enables you to create sophisticated, reactive UIs in pure Ruby, without touching JavaScript and HTML. You end up writing 50% less code while increasing productivity, maintainability and developer happiness.
Stars: ✭ 469 (+1279.41%)
Mutual labels:  ruby-gem, rubygem
ruby-sdk
♦️ Ruby SDK to use the IBM Watson services.
Stars: ✭ 45 (+32.35%)
Mutual labels:  ruby-gem, rubygem
Jekyll Minifier
Jekyll HTML/XML/CSS/JS Minifier utilising yui-compressor, and htmlcompressor
Stars: ✭ 215 (+532.35%)
Mutual labels:  jekyll-plugin, ruby-gem
ruby attic
💍 Unmaintained ruby projects needing people!
Stars: ✭ 26 (-23.53%)
Mutual labels:  ruby-gem, rubygem
Api Fuzzer
API Fuzzer which allows to fuzz request attributes using common pentesting techniques and lists vulnerabilities
Stars: ✭ 238 (+600%)
Mutual labels:  ruby-gem, rubygem
glimmer-dsl-tk
Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)
Stars: ✭ 26 (-23.53%)
Mutual labels:  ruby-gem, rubygem
Pages Gem
A simple Ruby Gem to bootstrap dependencies for setting up and maintaining a local Jekyll environment in sync with GitHub Pages
Stars: ✭ 1,670 (+4811.76%)
Mutual labels:  jekyll-plugin, ruby-gem
Jekyll Minibundle
A minimalistic asset bundling plugin for Jekyll
Stars: ✭ 65 (+91.18%)
Mutual labels:  jekyll-plugin, ruby-gem
ruby terraform
A simple Ruby wrapper for invoking terraform commands.
Stars: ✭ 92 (+170.59%)
Mutual labels:  ruby-gem, rubygem
glimmer-dsl-opal
Glimmer DSL for Opal (Pure-Ruby Web GUI and Auto-Webifier of Desktop Apps)
Stars: ✭ 22 (-35.29%)
Mutual labels:  ruby-gem, rubygem
Str metrics
Ruby gem (native extension in Rust) providing implementations of various string metrics
Stars: ✭ 68 (+100%)
Mutual labels:  ruby-gem, rubygem
Amp Jekyll
Build Accelerated Mobile Page versions of your Jekyll posts
Stars: ✭ 278 (+717.65%)
Mutual labels:  jekyll-plugin, ruby-gem
jekyll-extlinks
This Jekyll plugin adds custom attributes (rel="nofollow", target="_blank", etc.) to external links in your content.
Stars: ✭ 18 (-47.06%)
Mutual labels:  jekyll-plugin, ruby-gem
rarbg
Ruby client for the RARBG Torrent API.
Stars: ✭ 17 (-50%)
Mutual labels:  ruby-gem, rubygem
githat
Git diff with code syntax highlight
Stars: ✭ 32 (-5.88%)
Mutual labels:  ruby-gem
jekyll-portfolio-generator
Generates a portfolio/project pages (including related projects) out of data files
Stars: ✭ 55 (+61.76%)
Mutual labels:  jekyll-plugin
total
Ruby Gem to get total memory size in the system
Stars: ✭ 15 (-55.88%)
Mutual labels:  ruby-gem
precompress
Generate pre-compressed .gz and .br files for static web servers
Stars: ✭ 27 (-20.59%)
Mutual labels:  gzip

Jekyll::Gzip

Generate gzipped assets and files for your Jekyll site at build time.

Gem Version Build status Maintainability Inline docs

API docs | GitHub repo

Why?

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 you're making your webserver do it?

Why not just generate those gzip files at build time? And with the maximum compression too?

Jekyll::Gzip 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).

Want even more compression?

Zlib's gzipping capabilities don't quite squeeze all the compression out of our files that we could want. If you want a slower but better compression algorithm, check out Jekyll::Zopfli.

Zopfli is about the best compression we can get out of the gzip format, but there's more! Brotli is a relatively new compression format that is now supported by many browsers and can produce even smaller files. You can use brotli compression alongside gzip in your Sinatra app with Jekyll::Brotli.

Installation

Add Jekyll::Gzip to your application's dependencies:

group :jekyll_plugins do
  gem 'jekyll-gzip'
end

And then execute:

bundle install

Then add the plugin to the plugins key in your _config.yml

plugins:
  - jekyll-gzip

Usage

Once you have the gem installed, build your Jekyll site in production mode. On Mac/Linux you can run

JEKYLL_ENV=production bundle exec jekyll build

On Windows, set the JEKYLL_ENV environment variable to "production". Check out this blog post on setting environment variables on Windows. Then run:

bundle exec jekyll build

In your destination directory (_site by default) you will find gzipped versions of all your text files.

Jekyll::Gzip 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.

Configuration

Extensions

By default, Jekyll::Gzip will compress all files with the following extensions:

  • '.html'
  • '.css'
  • '.js'
  • '.json'
  • '.txt'
  • '.ttf'
  • '.atom'
  • '.stl'
  • '.xml'
  • '.svg'
  • '.eot'

You can supply your own extensions by adding a gzip 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:

gzip:
  extensions:
    - '.html'
    - '.css'
    - '.js

Replacing the original file

If you host your Jekyll site on AWS S3 you can take advantage of Jekyll::Gzip 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::Gzip turn the replace_files setting to true.

gzip:
  replace_files: true

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:

nginx

For nginx, you need to turn on the gzip_static module. Add the following in the relevant http, server or location block:

gzip_static on;

The 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.

Apache

In either a <Directory> section in your Apache config or in an .htaccess file, add the following:

AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]

Other web servers

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

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

Development

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 rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/philnash/jekyll-gzip. 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.

License

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

Code of Conduct

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].