Ruby on Rails Asset pipeline - Pro and Cons

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.

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?

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…

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

Thanks

Hi,

Yes, you can include seperate files when needed. But when the code is
minified in one. If you use the same file for every page of your
application, there will be few requests and the the CSS file and JS file
will be cached.

I advise this article which recaps the Asset Pipeline feature:
http://coderberry.me/blog/2012/04/24/asset-pipeline-for-dummies/

To create different independent stylesheet or javascript file, see this
question:

Q: How can I precompile additional assets without having to include them
in the manifest?

Generally in a website, the HTTP request is more longest than reading
process the code.

After if you’re not sure you can benchmark your application to see what
solution is the best.

Best regards.

Le dimanche 26 mai 2013 04:18:32 UTC+2, Keo Hoang M. a crit :

On Sat, May 25, 2013 at 9:18 PM, Keo Hoang M. [email protected]
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?