You can clone with
No one assigned
Here's a gem that already provides this behaviour: https://github.com/kenn/jquery-rails-cdn
I think this should be the default behaviour of the jquery-rails gem.
It seems like a waste of resources if we are all compiling our own copies of jQuery and jquery-ui into our application.js.
Sites like Twitter, Stack Overflow, Posterous, and Foursquare are ensuring that your users will already have a cached copy of jQuery ready for you to use, because they all reference Google's CDN. This provides cross-site caching.
You may find it helpful to read the following articles:
In order to implement this, we would need to provide an install generator (rails g jquery:install), since we'll need to make some changes to the Rails application:
rails g jquery:install
//= require jquery
= jquery_include_tag :google_schemeless
config.assets.precompile += ['jquery.js']
I agree that CDN support would be great if it's included in jquery-rails, but I also think jquery_include_tag sounds a bit too ugly to be the default to my taste.
To become as a default in Rails, better abstraction (no inclusion of jquery_ prefix) is needed IMO. cdn_ prefix, maybe?
Sooo... maybe I'm not getting something, but since there's already a gem that does this, why is it valuable to include this in jquery-rails?
I personally think it would be a good default. If a large majority of Rails apps are using jquery-rails, then I think they could all be using the jQuery hosted on Google's CDN.
Most developers won't care about this enough to do anything, so in order for the CDN idea to get any traction, it needs to be adopted by the gem they already use.
-1 this isn't appropriate for Ruby on Rails which takes Open Source very seriously. A rails app by default shouldn't rely on proprietary infrastructure. Also google gets ip addresses and referrers which can be logged when someone visits a site that has CDN jQuery and doesn't have it cached.
OK, I agree that the Open Source / proprietary infrustructure part makes some sense.
I am of the opinion that fetching jQuery from the Google CDN isn't a huge privacy risk, but the fact that it has been mentioned multiple times is enough to convince me that this idea isn't going to happen any time soon.
It's a shame though, since Google's CDNs does provide a great service with the best intentions, and it would become even more effective if more websites started using it.
Oh well, thanks for everyone's input. I will close this issue for now :)
This would mean having a separate request for jquery.
For anyone already using a CDN this could hurt performance.
@mariovisic It will only hurt the performance, if the specific version is not already in the browser cache. In most cases, it will, since many sites use Google's CDN. The widely used HTML5Boilerplate also uses Google's CDN for jQuery.
@ndbroadbent If there is any interest, I would develop a patch, which provides the functionality as an option, not enabled by default.
+1 by making this a default in rails it would help grow the base of sites out there, and increase the likelihood of any given browser having it cached
@ndbroadbent Exactly, if it's a default, most people will not change it without a good reason and everyone benefits. Anyone who wants to change it for a good reason (or a bad reason) is perfectly entitled to.
@ptrsghr, this isn't going to be added to jquery-rails. If you want your Rails site to serve jQuery from a CDN, use the "jquery-rails-cdn" gem instead.