Skip to content

Loading…

manifest gets included, duplicated javascript code #3742

Closed
beanieboi opened this Issue · 7 comments

4 participants

@beanieboi

hey

i encounter double includes in development mode when i use config.assets.debug = true, its ok if config.assets.debug = false

i renamed application.js to lomography.js

development.rb

config.assets.debug = true

lomography.js

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require mootools
//= require mootools_ujs
//= require username

html output

<script src="/assets/mootools.js?body=1" type="text/javascript"></script>
<script src="/assets/mootools_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/username.js?body=1" type="text/javascript"></script>
<script src="/assets/lomography.js?body=1" type="text/javascript"></script>

the lomography.js contains all the javascript again.
in my understanding lomography.js shouldn't be included at all in development mode.
i encountered the issue when i used link_to with :remote => true and a confirm message, because the confirm message was asked twice.

what else do you need?

@kennyj

I can't reproduct this problem.
Please tell us some informations.

1: your environment

$ ruby -v / rails -v

2: layout's javascript tags

ex) <%= javascript_include_tag "application" %>

3: config.assets.precompile setting

ex) config.assets.precompile += %w( search.js )

4: other config.assets settings

5: application.js

@beanieboi

hey kennyj

thats strange, i provide you with some more information

ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
rails -v
Rails 3.1.3

include tags:

 <link href="<%= asset_path('icon.png') %>" media="screen" rel="shortcut icon" type="image/x-icon" />
 <%= stylesheet_link_tag    "lomography" %>
 <%= javascript_include_tag "lomography" %>
 <%= csrf_meta_tag %>

this is only in my production.rb, not in development.rb!

config.assets.precompile += %w( lomography.js lomography.css backend.css)

i renamed the application.js to lomography.js and i pasted it before

HTH
ben

@atambo

Does your public/assets directory contain a lomography.js file? If so then I bet you are serving up the static public/assets lomography.js file with all of the compiled js and then your app also serves up all of the "requires" within the lomography.js because debug is on. You can get around this by either clearing out your public/assets directory or by setting config.assets.prefix to "/devassets" in your development.rb environment file.

@beanieboi

hey atambo,

it happens also when my public/assets is empty. also i see the log message "Served asset /lomography.js - 304 Not Modified (0ms)" it its not coming from my static asset folder.

i think it doesn't matter if there is something in my public/assets folder or not, because the only line of code which generates the javascript includes is

<%= javascript_include_tag "lomography" %>

this means, the include comes somewhere from rails

@kennyj

Just FYI.
According to sprockets's source,
if debug is true, it seems that Sprockets server have returned js in 2 way.

1: only lompgrapy.js when url has body=1
2: concated js when url has not body=1 (even if debug is true)

@beanieboi

hey,

i cant reproduce it neither. i don't know what i changed.
i made a new project and copied all the files to the new project and the link_to_remote is only called once.

i will close it now, since it seems only to happen in my project.

ben

@beanieboi beanieboi closed this
@cmezak

I'm also experiencing this problem when config.assets.debug is true. I think I'm getting one copy from the compiled application.js and another from the source js file (in the vendor/javascripts directory). My application.js explicitly includes the source file – otherwise it doesn't get included at all in production.

@azimux azimux pushed a commit to azimux/rails that referenced this issue
@tpope tpope Drop remaining script/plugin sources references
[#3742 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
e89ba63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.