Ruby on Rails Tuesday, July 30, 2013

Originally posted here

I am using Rails 3.2.1 where I have to include few controller and action specific javascripts which I am doing using a javascript_template_manager.html.haml and calling this at the bottom of the page. Now I want to combine all these js into one to reduce the http request. I am using asset pipeline.

How can I combine controller specific js into one precompiled file?

Here is how my _javascript_template_manager.html.haml file looks like:

 %noscript    :css      #container{ display:none; }    = render :partial => "/widgets/common/javascript_disabled"      = jquery_include_tag :google   = javascript_include_tag "common"    / condetional javascripts for the app  - if params[:controller] == "settings"    = javascript_include_tag "plugins/jQuery-cookie"    - if params[:controller] != "people" and params[:controller] != "companies"    = javascript_include_tag "plugins/iphone-style-checkboxes"    - if params[:controller] == 'users' || params[:controller] == 'companies'    = javascript_include_tag "plugins/best_in_place"    - if params[:controller] == 'letters' || params[:controller] == 'companies'    = javascript_include_tag "plugins/jquery.autoSuggest"    - if params[:controller] == 'people' || params[:controller] == 'letters' || params[:controller] == 'users' || params[:controller] == 'companies'    = javascript_include_tag "plugins/areacomplete"    = javascript_include_tag "application"

Now I want to combine all the above javascript files into one or what is the best way to do it?

- deepak 

--
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+unsubscribe@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/efe2a576-db41-459e-9462-4cb358e33799%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment