<commit_before># Best way to load latest jQuery in Ruby

Load jQuery from CDN in production and use local copy in development.
jQuery CDN supports Ruby on Rails, Sinatra ans other non-Rails environments
with Sprockets.

Another gem [jquery-rails](https://github.com/rails/jquery-rails) contain also
UJS adapter for jQuery. So it need to test any jQuery updates and release
new jQuery version after few month. If you don’t need UJS, this gem will be
better to you.

## Features

### Load from CDN

Public CDN is a best way to serve jQuery:

* **Speed**: users will be able to download jQuery from the closest physical
  location.
* **Caching**: CDN is used so widely that potentially your users may not need
  to download jQuery at all.
* **Parallelism**: browsers have a limitation on how many connections can
  be made to a single host. Using CDN for jQuery offloads a big one.

In development gem will use local copy of jQuery, so you can develop app
in airplane without Internet. In production gem will use CDN,
but if it will down, gem will automatically fallback to bundled jQuery.

### Latest version of jQuery

Instead of `jquery-rails` this gem always contain latest version of jQuery,
because it doesn’t need to test compatibility with UJS adapter.

For example, `jquery-rails`
[doesn’t support](https://github.com/rails/jquery-rails/issues/124)
jQuery 2 even after 4 months.

### Gem version is same that jQuery

Instead of `jquery-rails`, this gem versions tell exactly what jQuery is inside.
`Gemfile` maintaining will be much easy:

```ruby
gem 'jquery-cdn', '1.10.2' # Use jQuery 1.10.2
```

### Sinatra and plain Ruby support

You can use jQuery CDN with Ruby on Rails, Sinatra or any other Ruby environment
with Sprockets

## How To

### Ruby on Rails

Add `jquery-cdn` gem to your `Gemfile`:

```ruby
gem 'jquery-cdn'
```

If you support IE 6, 7 or 8, lock jQuery in 1.x versions:

```ruby
gem 'jquery-cdn', '~> 1.0'
```

Call `include_jquery` helper in layout:

```haml
!!! 5<commit_msg>Add about 2 branches to README.md<commit_after># Best way to load latest jQuery in Ruby

Load jQuery from CDN in production and use local copy in development.
jQuery CDN supports Ruby on Rails, Sinatra ans other non-Rails environments
with Sprockets.

Another gem [jquery-rails](https://github.com/rails/jquery-rails) contain also
UJS adapter for jQuery. So it need to test any jQuery updates and release
new jQuery version after few month (for example, there is still no jQuery 2
for `jquery-ujs`). If you don’t need UJS, this gem will be better to you.

jQuery CDN now has 2 branches: with jQuery 2.x and 1.x.

## Features

### Load from CDN

Public CDN is a best way to serve jQuery:

* **Speed**: users will be able to download jQuery from the closest physical
  location.
* **Caching**: CDN is used so widely that potentially your users may not need
  to download jQuery at all.
* **Parallelism**: browsers have a limitation on how many connections can
  be made to a single host. Using CDN for jQuery offloads a big one.

In development gem will use local copy of jQuery, so you can develop app
in airplane without Internet. In production gem will use CDN,
but if it will down, gem will automatically fallback to bundled jQuery.

### Latest version of jQuery

Instead of `jquery-rails` this gem always contain latest version of jQuery,
because it doesn’t need to test compatibility with UJS adapter.

For example, `jquery-rails`
[doesn’t support](https://github.com/rails/jquery-rails/issues/124)
jQuery 2 even after 4 months.

### Gem version is same that jQuery

Instead of `jquery-rails`, this gem versions tell exactly what jQuery is inside.
`Gemfile` maintaining will be much easy:

```ruby
gem 'jquery-cdn', '1.10.2' # Use jQuery 1.10.2
```

### Sinatra and plain Ruby support

You can use jQuery CDN with Ruby on Rails, Sinatra or any other Ruby environment
with Sprockets.

## How To

### Ruby on Rails

Add `jquery-cdn` gem to your `Gemfile`:

```ruby
gem 'jquery-cdn'
```

If you support IE 6, 7 or 8, lock jQuery in 1.x versions:

```ruby
gem 'jquery-cdn', '~> 1.0'
```

Call `include_jquery` helper in layout:

```haml
!!! 5
{'fraction_non_alphanumeric': 0.0829515312273933, 'fraction_numerical': 0.010851217747769471, 'mean_word_length': 4.108374384236453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '278488', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1178, 'n_words': 629}