Created
April 20, 2016 15:46
-
-
Save s-espinosa/36615cb982b8d7c5ecc6e06ec7c09e37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files? | |
Concatenated files are separate files that have been joined into a single file. Allows fewer calls to the server to get necessary information. | |
### What does it mean to precompile files? What does this have to do with coffeescript and sass files? | |
In this context, to turn files into something that your browser understands. Sass uses variables, etc. that can't be read by a browser looking for CSS. It then gets compiled into CSS so the browser can use it. | |
Similarly, Coffeescript is a more developer friendly language that compiles to javascript that the browser can then use. | |
### What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files? | |
Minified files have had whitespace removed, and variable naes simplified. Minifying helps shorten load time. | |
### 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? | |
Jquery was included as a gem, which then adds jquery locally to the asset pipeline even though there's no jquery file in either lib or vendor. It looks like it's also included in the application.js manifest. | |
### What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch 'em All? | |
A manifest is a file that tells rails Sprockets what files to include when building single concatenated js or CSS files. | |
application.js serves as a manifest and has the following directives in Catch 'em All. | |
//= require jquery | |
//= require jquery_ujs | |
//= require turbolinks | |
//= require_tree . | |
application.css has the following directives. | |
*= 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? | |
With a link_to in the head of the page where you want to use the css that automatically picks up the compiled/minified file from the asset pipeline. | |
Catch 'em All has the following line in the head of the application.html.erb file. | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> | |
### How is a digest/fingerprint used on the assets for caching purposes? | |
Fingerprinting changes the names of files served to break through caches when the underlying assets have been changed. Generally caching uses file names to find cached assets, so if the file name has changed the cache will assume that it is a new asset. | |
### Done? Take a look at RailsGuides: The Asset Pipeline. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In regular HTML files, we bring in css files with . How is this done in a Rails project? Where do you see this line in Catch 'em All? --- Its not really a
link_to
but the idea is the same👍