respond-rails

A fast & lightweight polyfill for min/max-width CSS3 Media Queries (for IE 6-8, and more)


Install
gem install respond-rails -v 1.0.1

Documentation

respond-rails

Respond.js provides a fast and lightweight script to enable responsive web designs in browsers that don't support CSS3 media queries. You can find the original source repository at https://github.com/scottjehl/Respond.

Installation

Include the gem in your Gemfile:

    gem "respond-rails", "~> 1.0"

Include Respond.js in your application layout like so:

    <%= respond_include_tags %>

And add respond.js to the list of precompiled assets:

# config/environments/production.rb

config.assets.precompile += %w( modernizr.js respond.js respond-proxy.html respond.proxy.js )

CDN/X-Domain Setup

If you store your assets on a separate host, you'll need to edit asset_host like so:

# config/environments/production.rb

config.action_controller.asset_host = Proc.new { |source, request|
  if source =~ /respond\.proxy-.+(js|gif)$/
    "#{request.protocol}#{request.host_with_port}"
  else
    "//assets.example.com"
  end
}

This will skip the asset_host for respond.proxy.js and respond.proxy.gif which need to be on the same domain. After that, you'll need to make an addition to the precompiled assets:

config.assets.precompile += %w( respond.js respond-proxy.html respond.proxy.js )

Copyright

Copyright (c) 2011 Scott Jehl, scottjehl.com

See https://github.com/scottjehl/Respond for details.