jquery-rails-cdn 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +24 -9
- data/lib/jquery-rails-cdn.rb +6 -4
- data/lib/jquery-rails-cdn/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -8,19 +8,26 @@ Serving jQuery from a publicly available [CDN](http://en.wikipedia.org/wiki/Cont
|
|
8
8
|
* **Caching**: CDN is used so widely that potentially your users may not need to download jQuery at all.
|
9
9
|
* **Parallelism**: Browsers have a limitation on how many connections can be made to a single host. Using CDN for jQuery offloads a big one.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
* Updating your js code won't evict the entire cache in browsers - your code changes more often than jQuery upgrades, right?
|
14
|
-
* `rake assets:precompile` takes less time and less peak memory usage.
|
11
|
+
## Features
|
15
12
|
|
16
|
-
This gem
|
13
|
+
This gem offers the following features:
|
17
14
|
|
18
15
|
* Supports multiple CDN. (Google, Microsoft and jquery.com)
|
19
16
|
* jQuery version is automatically detected via jquery-rails.
|
20
|
-
* Automatically fallback to jquery-rails' bundled
|
17
|
+
* Automatically fallback to jquery-rails' bundled jQuery when:
|
21
18
|
* You're on a development environment, so that you can work offline.
|
22
19
|
* The CDN is down or unavailable.
|
23
20
|
|
21
|
+
On top of that, if you're using asset pipeline, you may have noticed that the major chunks of the code in `application.js` is jQuery. Implications of externalizing jQuery from `application.js` are:
|
22
|
+
|
23
|
+
* Updating your js code won't evict the entire cache in browsers - your code changes more often than jQuery upgrades, right?
|
24
|
+
* `rake assets:precompile` takes less peak memory usage.
|
25
|
+
|
26
|
+
Changelog:
|
27
|
+
|
28
|
+
* v0.1.0: Added :google_schemeless for sites that support both ssl / non-ssl
|
29
|
+
* v0.0.1: Initial release
|
30
|
+
|
24
31
|
## Installation
|
25
32
|
|
26
33
|
Add this line to your application's Gemfile:
|
@@ -33,7 +40,7 @@ gem 'jquery-rails-cdn'
|
|
33
40
|
|
34
41
|
This gem adds two methods `jquery_include_tag` and `jquery_url` to generate a script tag to the jQuery on a CDN of your preference.
|
35
42
|
|
36
|
-
If you're using asset pipeline with Rails 3.1+, first remove
|
43
|
+
If you're using asset pipeline with Rails 3.1+, first remove `//= require jquery` from `application.js`.
|
37
44
|
|
38
45
|
Then in layout:
|
39
46
|
|
@@ -42,7 +49,15 @@ Then in layout:
|
|
42
49
|
= javascript_include_tag 'application'
|
43
50
|
```
|
44
51
|
|
45
|
-
Note that valid CDN symbols are
|
52
|
+
Note that valid CDN symbols are:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
:google
|
56
|
+
:google_ssl
|
57
|
+
:google_schemeless
|
58
|
+
:microsoft
|
59
|
+
:jquery
|
60
|
+
```
|
46
61
|
|
47
62
|
It will generate the following on production:
|
48
63
|
|
@@ -50,7 +65,7 @@ It will generate the following on production:
|
|
50
65
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
|
51
66
|
<script type="text/javascript">
|
52
67
|
//<![CDATA[
|
53
|
-
window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery.js
|
68
|
+
window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery-86b29a215ef746103e2469f095a4df9e.js" type="text/javascript">%3C/script>'))
|
54
69
|
//]]>
|
55
70
|
</script>
|
56
71
|
```
|
data/lib/jquery-rails-cdn.rb
CHANGED
@@ -3,12 +3,14 @@ require 'jquery-rails-cdn/version'
|
|
3
3
|
|
4
4
|
module Jquery::Rails::Cdn
|
5
5
|
module ActionViewExtensions
|
6
|
+
JQUERY_VERSION = Jquery::Rails::JQUERY_VERSION
|
6
7
|
OFFLINE = (Rails.env.development? or Rails.env.test?)
|
7
8
|
URL = {
|
8
|
-
:google
|
9
|
-
:google_ssl
|
10
|
-
:
|
11
|
-
:
|
9
|
+
:google => "http://ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
|
10
|
+
:google_ssl => "https://ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
|
11
|
+
:google_schemeless => "//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
|
12
|
+
:microsoft => "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js",
|
13
|
+
:jquery => "http://code.jquery.com/jquery-#{JQUERY_VERSION}.min.js"
|
12
14
|
}
|
13
15
|
|
14
16
|
def jquery_url(name, options = {})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-rails-cdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|