rails/rails — Issue #5095: jQuery is included twice
Author: dnagir
Created: 2012-02-20 04:19:52+00:00
State: open

In development mode the jquery is included twice: 1st time as a separate file `/assets/jquery.js` and then embedded into `/assets/application.js`.

This effectively makes it impossible to properly use jquery and all the related stuff in development environment.

Repro:

```bash
> rails -v
Rails 3.2.1

> rails new jq2
# Wait for stuff to be bundled...

> cd jq2/
> rails s -d
> curl http://localhost:3000/assets/jquery.js | head -n 2
/*!
* jQuery JavaScript Library v1.7.1

> curl http://localhost:3000/assets/application.js | head -n 2
/*!
* jQuery JavaScript Library v1.7.1

```

The real problem seems to be that the `application.js` expands the `jquery.js` and includes it into the page BUT doesn't exclude it itself.

As a result jQuery is loaded twice (from `jquery.js` and `application.js`):

```bash
> rails g scaffold pages
> bundle exec rake db:migrate
> rails s -d

> curl http://localhost:3000/pages | grep ".js"

```

I 'm not sure why it hasn't been reported before (or has it?) as it seems to break a lot of things.