Thanks for the update. jquery.bxslider.min.js in my case is not part of application.js
I have added jquery.bxslider.min.js to pre-compile path also, so that it can be loaded independently. Its available in public/assets folder too. You said "I'm not surprised it is re-compiling the source code at runtime."..I totally agree. However that should happen when browser request that very particular asset, not while creating page response that has <script src="jquery.bxslider.min.js"></script> in the markup. Am I going astray here in making you understand the issue. Let me know. On Thursday, 11 July 2013 21:58:03 UTC+5:30, mike wrote: > > > > On Thursday, July 11, 2013 7:24:34 AM UTC-4, farukhdm wrote: >> >> Hi, >> >> I am stuck in a weird situation where in my production environment, an >> asset is being attempted to compress while rendering a view. >> I've all my assets put into public/assets folder via rake >> "assets:precompile" >> >> production.rb has following configurations: >> -------------------------------------------------------------- >> # Disable live compilation of assets(Don't fallback to assets pipeline >> if a precompiled asset is missed) >> config.assets.compile = false >> >> # Assets pre-compilation task(rake assets:precompile) configurations >> config.assets.css_compressor = :yui >> config.assets.js_compressor = :yui >> config.assets.compress = true >> >> >> When I request for some page let say http://www.example.com/home, while >> generating the page response, Rails is trying to compress an asset named >> "jquery.bxslider.min" >> >> I've following code that is creating error. >> >> <%= content_for :js_include do %> >> <%= javascript_include_tag 'jquery.bxslider.min' %> >> <% end %> >> >> Error in log: >> ============= >> ActionView::Template::Error (undefined method `exitstatus' for nil:NilClass >> (in /example/lib/assets/javascripts/jquery.bxslider.min.js)): >> 57: <%= content_for :js_include do %> >> 58: <%= javascript_include_tag 'jquery.bxslider.min' %> >> 59: <% end %> >> >> >> The error is however for missing java(as I'm using YUI for compression, >> which depends on java) >> >> I don't want any live compression & compilation, as assets are already >> available in public/assets folder >> >> >> I am surprised, why Rails is trying to compress asset while rendering an >> action. >> >> >> Please advise. >> >> >> Regards >> >> Farukh D M >> > > I'm not surprised it is re-compiling the source code at runtime. You have > to be careful with javascript_include_tag when you are using the asset > pipeline. When you precompile your assets, everything is put into one js > file with a long, cryptic name that looks something like the following in > html: > > <script > src="/assets/application-931a21730f0f60d50be598cdd891dccf.js"></script> > > When you then insert a javascript tag, it's going to look like the > following in your html: > > <script src="jquery.bxslider.min.js"></script> > > The browser is going to attempt to load both files. It doesn't detect > that the contents of jquery.bxslider.min.js are actually already in the > first file. Because this file is located in the /app/assets/js directory, > it's going to be processed by rails through the asset compiler when the > browser requests the file. > > You shouldn't reference a javascript file in a script tag if you've > already included it in the asset pipeline unless you truly intend to load > it twice. > > If you have javascript you want to load independent of the asset pipeline > and you don't want it processed through the asset compiler, you should > reference it in a javascript_include_tag as you have done above, but you > should locate the file in the public/js directory. > > > > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/629a2444-45f2-41b8-826e-7ef6864d31a4%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.