Skip to content

Instantly share code, notes, and snippets.

@Cdale3
Created April 12, 2017 19:36
Show Gist options
  • Save Cdale3/cf86bfdb4f2514762ab0d32453b4afc5 to your computer and use it in GitHub Desktop.
Save Cdale3/cf86bfdb4f2514762ab0d32453b4afc5 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? Concatenate is the combining of more than one files/strings/other elements to eachother. The asset pipeline provides us a framework to concatenate and minify or compress JavaScript and CSS assets. By combining these files we are reducing the number of requests that a browser must make to render a web page.
What does it mean to precompile files? What does this have to do with coffeescript and sass files?
Rails will place files where they may be more easily accessed and delivered to the server. CoffeeScript and Sass are the tools rails uses to code these assets - Sass is for CSS and CoffeeScript is for JavaScript, erb is for both. if you add an erb extension to a JavaScript asset making it something like file_name.js.erb, then you can use an asset_path helper in your javascript code. You could also add CoffeeScript to that same file making it file_name.js.coffee.erb
What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?
Minify removes whitespace and comments. I believe to make things smaller and more compact and to try and fit into the "fastest by default" practices that rails implements.
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?
Files are rendered into a concatenated form on the page, where the code is the manifest for these commands to perform that action.
What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch ‘em All?
Manifests provide a structure on how the files will be compiled even when files have changed between requests, the server responds with a new compiled file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment