Module: Hancock::GzipHelper
- Defined in:
- app/helpers/hancock/gzip_helper.rb
Instance Method Summary collapse
Instance Method Details
#gzip_javascript_include_tag(*sources) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/hancock/gzip_helper.rb', line 2 def gzip_javascript_include_tag(*sources) # Grab the asset html include tag tag = javascript_include_tag(*sources) # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset if Rails.env.production? && request.accept_encoding =~ /gzip/i tag = tag.gsub(/\.js/i, ".js.gz") end # Return the asset whether or not it was modified tag.html_safe end |
#gzip_stylesheet_link_tag(*sources) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/hancock/gzip_helper.rb', line 15 def gzip_stylesheet_link_tag(*sources) # Grab the asset html include tag tag = stylesheet_link_tag(*sources) # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset if Rails.env.production? && request.accept_encoding =~ /gzip/i tag = tag.gsub(/\.css/i, ".css.gz") end # Return the asset whether or not it was modified tag.html_safe end |