Skip to content

Instantly share code, notes, and snippets.

@jwashke
Last active April 20, 2016 20:11
Show Gist options
  • Save jwashke/8410625390c864762d76aef0052aae41 to your computer and use it in GitHub Desktop.
Save jwashke/8410625390c864762d76aef0052aae41 to your computer and use it in GitHub Desktop.
  • What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
    • Putting multiple files into one. Like taking several CSS files and putting them all into one CSS file so that only one HTTP request has to be made for a single stylesheet
  • What does it mean to precompile files? What does this have to do with coffeescript and sass files?
    • Sass and CoffeeScript are written in .scss files and .coffee files. They are precompiled which runs thems through an interpreter outputting regular CSS and JavaScript files for the application to use.
  • What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files? alt
    • To minify files is to remove the whitespace from those files. You would want to do this because over a lot of http requests, the size and bandwidth that whitespace is taking is marginal at first but begins to add up.
  • 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?
    • The running application file has jquery concatenated into it.
  • What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch 'em All?
    • A manifest is a main file where you put your require trees to require other related files. The two in Catch 'em All are the base application.js and application.css.scss files
  • 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?
    • In rails it seems to be used in a stylesheet_link_tag in application.html.erb, but rails will pull any stylesheets in the proper folder into your application for you.
  • How is a digest/fingerprint used on the assets for caching purposes?
    • The digest is used for caching as a way to know if changes were made to a file. If any change is made to the file then the digest changes which lets the asset pipeline know that the cached version is out of date.
  • Done? Take a look at RailsGuides: The Asset Pipeline.
    • Ok I will.
@Carmer
Copy link

Carmer commented Apr 20, 2016

The manifest includes that/=require tree . statement tells the pipeline what to compile/concatenate/minify. /=require tree . is a part of the manifest but is not the manifest. Instead of require tree we could just require individual files and those individual files would make up the manifest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment