Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created February 21, 2011 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjmcewan/836481 to your computer and use it in GitHub Desktop.
Save tjmcewan/836481 to your computer and use it in GitHub Desktop.
env-aware jQuery includes
def jquery_includes
jquery_version = "1.4.4"
jquery_ui_version = "1.8.9"
css_theme = "redmond"
if ::Rails.env == 'production'
proto = request.ssl? ? 'https://' : 'http://'
cdn_url = "ajax.googleapis.com/ajax/libs/jquery"
javascript_include_tag("#{proto}#{cdn_url}/#{jquery_version}/jquery.min.js") +
javascript_include_tag("#{proto}#{cdn_url}ui/#{jquery_ui_version}/jquery-ui.min.js") +
stylesheet_link_tag("#{proto}#{cdn_url}ui/#{jquery_ui_version}/themes/#{css_theme}/jquery-ui.css")
else
javascript_include_tag("jquery-#{jquery_version}", "jquery-ui-#{jquery_ui_version}") +
stylesheet_link_tag("jquery-ui-#{jquery_ui_version}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment