Sunday, May 26, 2013

Re: [Rails] Ruby on Rails Asset pipeline - Pro and Cons

On Sat, May 25, 2013 at 9:18 PM, Keo Hoang Minh <keohoangminh@gmail.com> wrote:
> I was in chapter 5 of the Ruby on Rails, and I come across "Asset pipeline"
> when R-o-R detect and jam all css and js files into one.

Bundles are quite common now. Even for non Rails-ists.

> It's true that Browser will have to make less requests, but at the same
> time, the browser will potentially have to process more code than it should?

It's true it will make less requests, it's false that it will require
more processing, it will require the same amount of processing whether
split up into 10 requests or 1. That is if we discount all the other
processing that happens before and after the parsing of your sources.

> For example, I use a slider jquery plugin in gallery page, since R-o-R fuse
> the plugin with all other js files into 1 javascript.js, the plugin will be
> included in about page, home page and so on...

You can create separate bundles that don't include everything,
application.js should give you an example on your first install, and
even if it does not the source that is there is pretty self
explanatory if you ask me. And even if you just drop it from the
bundles period you can still require it individually by hitting up
/assets/name.js.

> Can I import separated files for separated pages? and how?

https://github.com/sstephenson/sprockets#the-directive-processor

--
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/CAM5XQnxBPK8E5V5ma1iMzCEySi2%2B_4KSHemPQSsVLp%2Bfpqfnsw%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment