Skip to content

Instantly share code, notes, and snippets.

@marinacor1
Created April 20, 2016 17:49
Show Gist options
  • Save marinacor1/780dcf49224741e673352bb9e3b9cb0e to your computer and use it in GitHub Desktop.
Save marinacor1/780dcf49224741e673352bb9e3b9cb0e to your computer and use it in GitHub Desktop.
Learning about asset pipeline
What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
Combine folders into one. We want to concatenate to save space, make it easier to file/ find. Reduce the number of requests that a browser makes to render a web page. (faster loading)
http://www.jddesign.co.uk/products/concat/readme/concatdialog.png
What does it mean to precompile files? What does this have to do with coffeescript and sass files?
A precompiled header is file that is precompiled to make it faster to process.
What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?
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?
What is a manifest (in terms of the asset pipeline)? Where can you find two manifests in Catch 'em All?
Manifest files are used by sprocket to determine which assets to include and serve. files contain directives- instructions that tell sprockets which files to require in order to build a single CSS or JavaScript file. Sprocket manipulates them. Load time is less because less requests.
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?
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
How is a digest/fingerprint used on the assets for caching purposes?
-The fingerprint is cached by the web browser (and the fingerprint changes everytime you change something within the file)
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