CSC/ECE 517 Fall 2014/ch1a 22 sp: Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
==Rake Pipelining: Asset Pipelining in Rails== | ==Rake Pipelining: Asset Pipelining in Rails== | ||
; What is a Ruby on Rails asset pipeline? | ; What is a Ruby on Rails asset pipeline? | ||
: Generally speaking, asset pipelining refers to the practice of using a provided framework to combine and/or minify (compress) assets. This framework also allows these assets to be written and precompiled with different languages such as CoffeeScript and embedded Ruby.<ref>[http://guides.rubyonrails.org/asset_pipeline.html "The Asset Pipeline"], ''Rails Guides''. Retrieved | : Generally speaking, asset pipelining refers to the practice of using a provided framework to combine and/or minify (compress) assets. This framework also allows these assets to be written and precompiled with different languages such as CoffeeScript and embedded Ruby.<ref>[http://guides.rubyonrails.org/asset_pipeline.html "The Asset Pipeline"], ''Rails Guides''. Retrieved 16 September 2014.</ref> | ||
The three main features outlined above are all good reasons to include an asset pipeline in a Rails application. | The three main features outlined above are all good reasons to include an asset pipeline in a Rails application. | ||
Line 11: | Line 11: | ||
#* Apart from GZIP compression, minification can also have a significant impact on the number of bits that your application needs to send down the wire. | #* Apart from GZIP compression, minification can also have a significant impact on the number of bits that your application needs to send down the wire. | ||
#* Remember, it's not just about the amount of data, it's also about the number of requests required to get the data from the server to the browser. Too many requests can have a greater impact on application performance than file size.<ref>[http://www.hanselman.com/blog/TheImportanceAndEaseOfMinifyingYourCSSAndJavaScriptAndOptimizingPNGsForYourBlogOrWebsite.aspx "The Importance (and Ease) of Minifying your CSS and JavaScript and Optimizing PNGs for your Blog or Website"], ''Scott Hanselman''. 1 September 2011. Retrieved on 16 September 2014.</ref> | #* Remember, it's not just about the amount of data, it's also about the number of requests required to get the data from the server to the browser. Too many requests can have a greater impact on application performance than file size.<ref>[http://www.hanselman.com/blog/TheImportanceAndEaseOfMinifyingYourCSSAndJavaScriptAndOptimizingPNGsForYourBlogOrWebsite.aspx "The Importance (and Ease) of Minifying your CSS and JavaScript and Optimizing PNGs for your Blog or Website"], ''Scott Hanselman''. 1 September 2011. Retrieved on 16 September 2014.</ref> | ||
# Precompilation (preprocessing) | |||
#* When using an asset pipeline, assets may be coded in a higher-level language and then precompiled down to the actual assets. | |||
#* Furthermore, multiple levels of preprocessing may be used simply by appending additional file extensions to the file name. For example, 'app/assets/stylesheets/projects.css.scss.erb' can be first processed as ERB, then SCSS, and finally served as CSS. | |||
Revision as of 01:36, 18 September 2014
Sprockets gem provides Sprockets implementation for Rails 4.x (and beyond) Asset Pipeline. This wiki must describe importance of using asset pipelining in Rails (now called rake pipelining), how its done? A Pipeline is responsible for taking a directory of input files, applying a number of filters to the inputs, and outputting them into an output directory. Also include details to implement Rails 4 asset pipeline on Heroku.
Rake Pipelining: Asset Pipelining in Rails
- What is a Ruby on Rails asset pipeline?
- Generally speaking, asset pipelining refers to the practice of using a provided framework to combine and/or minify (compress) assets. This framework also allows these assets to be written and precompiled with different languages such as CoffeeScript and embedded Ruby.<ref>"The Asset Pipeline", Rails Guides. Retrieved 16 September 2014.</ref>
The three main features outlined above are all good reasons to include an asset pipeline in a Rails application.
- Asset concatenation
- Concatenating assets means that the browser needs to make fewer requests to render the page, which means that your application will load faster.
- Asset minification
- Apart from GZIP compression, minification can also have a significant impact on the number of bits that your application needs to send down the wire.
- Remember, it's not just about the amount of data, it's also about the number of requests required to get the data from the server to the browser. Too many requests can have a greater impact on application performance than file size.<ref>"The Importance (and Ease) of Minifying your CSS and JavaScript and Optimizing PNGs for your Blog or Website", Scott Hanselman. 1 September 2011. Retrieved on 16 September 2014.</ref>
- Precompilation (preprocessing)
- When using an asset pipeline, assets may be coded in a higher-level language and then precompiled down to the actual assets.
- Furthermore, multiple levels of preprocessing may be used simply by appending additional file extensions to the file name. For example, 'app/assets/stylesheets/projects.css.scss.erb' can be first processed as ERB, then SCSS, and finally served as CSS.
How-To
Rails 4 Asset Pipelines on Heroku
<ref>"Rails 4 Asset Pipeline on Heroku", Heroku Dev Center. 10 April 2014. Retrieved 16 September 2014</ref> <ref>"Rails Asset Pipeline on Heroku Cedar", Heroku Dev Center. 25 August 2014. Retrieved 16 September 2014</ref>
References
<references/>