Skip to content

Instantly share code, notes, and snippets.

@iwarner
Created May 4, 2013 04:29
Show Gist options
  • Save iwarner/5516184 to your computer and use it in GitHub Desktop.
Save iwarner/5516184 to your computer and use it in GitHub Desktop.
Middleman - GZIP Content - 3.0.x branch
### Create GZIP Content Helper
### Add this snippet to the config.rb
### Add the activate :gzip to the build section
helpers do
def gzip_css_on_build(key, media = "screen")
o = stylesheet_link_tag(key, { :media => media })
o.sub!(".css", ".css.gz") if build?
o
end
def gzip_js_on_build(key)
o = javascript_include_tag(key)
o.sub!(".js", ".js.gz") if build?
o
end
end
### Build-specific configuration
configure :build do
# GZIP Files
activate :gzip
end
-# In your layout include the stylesheets with
= gzip_css_on_build "site", "all"
-# And the Javascript with
= gzip_js_on_build :all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment