Skip to content

Instantly share code, notes, and snippets.

@lukyans
Created April 12, 2017 20:11
Show Gist options
  • Save lukyans/960673851473dc93720d90f5b829fa50 to your computer and use it in GitHub Desktop.
Save lukyans/960673851473dc93720d90f5b829fa50 to your computer and use it in GitHub Desktop.
Asset Pipeline Scavenger Hunt
What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
-Concatenation is very important in the production environment. It can reduce the number of requests that a browser makes to render a web page, which leads to faster load time.
```
What does it mean to precompile files? What does this have to do with coffeescript and sass files?
-Precompilation let’s you use higher-level languages to create actual assets (for example, Sass to CSS).
```
What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?
Minification takes out the extra whitespace and comments from your assets. This allows for smaller asset file size, which leads to faster load times.
https://cdn.keycdn.com/support/wp-content/uploads/2016/02/minify-javascript.png
```
Start up the server for Catch ‘em All (rails s) and navigate to http://localhost:3000/assets/application.js. Then open up the code for application.js in your text editor. Why are these not the same?
-This is a manifest file that'll be compiled into application.js, which will include all the files
```
What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch ‘em All?
-The keystone of the asset pipeline is the manifest file. By default, Rails creates one for stylesheets (app/assets/stylesheets/application.css) and JavaScript files (app/assets/javascripts/application.js). This file uses directives to declare dependencies in asset source files.
in application.js
//= require_tree .
in application.css.scss
*= require_tree .
*= require_self
```
In regular HTML files, we bring in css files with <link rel="stylesheet" href="application.css">. How is this done in a Rails project? Where do you see this line in Catch ‘em All?
//= require jquery
//= require jquery_ujs
```
How is a digest/fingerprint used on the assets for caching purposes?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment