Skip to content

Instantly share code, notes, and snippets.

@afg419
Last active January 13, 2016 19:50
Show Gist options
  • Save afg419/a5c1f160b009d2287270 to your computer and use it in GitHub Desktop.
Save afg419/a5c1f160b009d2287270 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?

Puts the files together. Single GET request to get both files.

What does it mean to precompile files? What does this have to do with coffeescript and sass files?

Compiling means convert to machine code. Precompiling is therefore compiling before the app runs. Coffeescript and sass files are not precompiled directly. Coffeescript and sass are higher languages than css and js, they compile first to css and js, then compiled to machine code.

What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?

Take outs unnecessary characters. Smaller file size when minified, so less to send.

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 localhost version includes the text for all the files jquery (from gemfile), jquery_ujs, turbolinks, tree. (tree recursively requires all the js files in the js folder.)

What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch 'em All?

Manifests are the actual files that get sent, and they draw in required files contained within their code. Two examples are application.js and application.css.

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?

In Rails, the application.html.erb file includes the html corresponding to this css file. In Catch 'em All it is on lines 5 and 6 of application.html.erb.

How is a digest/fingerprint used on the assets for caching purposes?

Fingerprinting changes the filename to reference the file's content. It's useful because when a file is cached, but then its digest changes, it tells the client to request the new version.

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