Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
javascript_include_tag :all, :cache => true
5 Posts
javascript_include_tag :all, :cache => true

Hi

While surfing one of the rails blog i found using true %> in layout increases the performance of page loads

Does it include only the "default" javascript files or all the files in the javascript directory?

When i tried using it in my layout, i got cannot dup symbols error

Was bit curious is it a rails 2 feature or available in lower versions also?

Person
Forum Rating: 100
Sign In To Rate Post

Balaji,

Yes, javascript_include_tag :all, :cache => true is a new feature added to Rails 2.x and it will grab all the js files within the javascripts directory. This post (http://davetroy.blogspot.com/2007/12/automatic-asset-minimization-and.html) will show you how to implement the :cache => true behaviour in your non 2.x apps.

Regards.

Thanks a lot Nuwan

Person
Forum Rating: 100
Sign In To Rate Post

If you want specific files only or you need to specify the order you can do:

true %>

Person
Sr. Ruby & Rails Consultant For Hire
Sign In To Rate Post

Keep in mind that if you use :all and you have stylesheets that redefine the same elements, only one will take precidence.

For example if a.css defines id "#top", b.css defines id "#top" and c.css defines id "#top", only one of these will actually be active in the browser, even though it will be listed in the cache css file.

This is only important if you are dynamically needing different CSS depending upon conditions set in your application (like sub-sites, user selected theming, etc).

-Kevin Elliott "WeLikeFood Beta":http://www.welikefood.com Discover great restaurants. Discover great food enthusiasts with your taste.

5 Posts
Login to add your message