Skip to content

Instantly share code, notes, and snippets.

@samlandfried
Last active April 12, 2017 15:52
Show Gist options
  • Save samlandfried/12d140094c7d2a45d413462048074cd8 to your computer and use it in GitHub Desktop.
Save samlandfried/12d140094c7d2a45d413462048074cd8 to your computer and use it in GitHub Desktop.
asset_pipeline_scav_hunt.md
  1. What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
  • File concatenation is combining files. This saves us time when loading assets because the browser needs to make fewer external calls.
  1. What does it mean to precompile files? What does this have to do with coffeescript and sass files?
  • Precompiling converts higher level languages into their base language. SASS -> CSS. Coffeescript -> Javascript.
  1. What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?
  • Minifying a file reduces it to the smallest size possible while retaining its functionality. For example, variable names are compressed to single letter values, and white space is stripped out.
  1. 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?
  • I think that the file in the browser has all the other JS assets concatenated into it.
  1. What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch ‘em All?
  • application.js and application.css.scss. Both tell Rails what assets to be loaded into the pipeline.
  1. 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?
  • This is done via the manifest file's directives. In Catch 'em All, those are the commented lines that say something like *=jquery
  1. How is a digest/fingerprint used on the assets for caching purposes?
  • A fingerprint is a filename that is unique to that file's contents. If the file contents change, the file name changes. This allows servers to use cached resources with confidence. There's no reason to re-request a resource if it already has the resource in its cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment