public
Description: Use Google's copies of major Javascript libraries instead of the local copies.
Homepage:
Clone URL: git://github.com/chriswarren/include_google_js.git
100644 44 lines (27 sloc) 1.498 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
IncludeGoogleJs
===============
 
Allows you to easily use Google's hosted javascript libraries instead of your own copies, lightening the load for your server and for your visitors.
 
IncludeGoogleJs will override javascript_include_tag to use Google's hosted Javascript libraries instead of the local copies, as explained at
http://ajaxian.com/archives/announcing-ajax-libraries-api-speed-up-your-ajax-apps-with-googles-infrastructure
and announced at
http://googleajaxsearchapi.blogspot.com/2008/05/speed-up-access-to-your-favorite.html
 
Acts like the regular javascript_include_tag, but adds :include_google_js and :version options.
Gets the requested files and swaps out any that Google hosts.
Checks for a working connection to ajax.googleapis.com before switching over.
 
Versions are based on the version running locally, or can be overridden by passing :versions => {:scriptaculous => "1.5", :jquery => "1.3.2"}.
 
Should work with Rails > 2.0.
 
Thanks to Brian Hogan and Jose Fernandez for their help.
 
Installation
=======
 
From git:
ruby script/plugin install git://github.com/chriswarren/include_google_js.git
 
 
Examples
=======
 
Pass
 
:include_google_js => true
 
as an option to javascript_include_tag to use Google's copy instead of the local copy.
 
---
Pass
 
:versions => {:scriptaculous => "1.8", :prototype => "1.6"}
 
as an option to javascript_include_tag to specify the version of a library to retrieve.
 
Copyright (c) 2008-2009 Christopher Warren, released under the MIT license