Javascript/CSS asset bundling a prominent feature in Rails 2.0
posted: September 12th, 2007 · by: Sven
Hey, I just noticed that bundled Javascript and CSS assets will be supported natively in Rails 2.0! David even selected this feature as one of those prominent Rails 2.0 features that he presented during his keynote at the RailsConf Chicago 2007 on May 18th.
Actually this stuff even is in Rails Edge ever since February! So in Rails Edge we already can do this:
<%= javascript_include_tag :all, :cache => true %>
<%= stylesheet_link_tag :all, :cache => true %>
Or more flexibly:
<%= stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" %>
That’s cool :)
And it’s pretty much the same what my own Bundled Assets plugin does … besides: my plugin also “compacts” Javascript and CSS by stripping things like comments and whitespace - and it still works on Rails 1.2 of course.
Huh. Wow!
polypus said October 25th, 2007 at 05:48 AM ¶
huh, so i guess the new native to rails version does not do any ‘compression’? does your plugin work on rails 2.0?
thanks, _c
Sven Fuchs said October 26th, 2007 at 02:07 PM ¶
Hi polypus,
actually, I haven’t tested that, yet. I’d love to learn about your results if you want to give it a try :)
This blogs runs on a Rails revision 7404 which isn’t that old. Also, I can’t see why it wouldn’t work on Rails 2.0 … but of course, you never really know before you try it.