Skip to content

Instantly share code, notes, and snippets.

@lingtran
Last active April 20, 2016 20:17
Show Gist options
  • Save lingtran/ec4454723207c8343f6bde2ec8295dc2 to your computer and use it in GitHub Desktop.
Save lingtran/ec4454723207c8343f6bde2ec8295dc2 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?

  • To append one file to another
  • Merge data of one file with another (or multiple other files)
  • Example image: http://i.stack.imgur.com/eaepe.png (something like this?)
  • Intention for file concatenation: Minimize the number of requests made to the server, therefore optimizing client-side performance (such as enabling faster page load time)

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

  • Specifies what files are to be processed by the asset pipeline
  • Sass and Coffeescript are languages that use preprocessors to transform their syntax into CSS and Javascript, respectively. Sass and Coffeescript are included by default with Rails.

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

  • Minification is the process of removing all unnecessary characters from source code without changing its functionality. Unncessary characters include white space characters, new line characters, comments, and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute.
  • This reduces the amount of data that needs to be processed, which goes back to performance optimization
  • Example image: http://cdn.speedrak.com/images/blog-images/seoblogger-after-minify-css.PNG

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?

  • Code in the js file was commented out

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

  • Directives files that determine which assets to include and serve
  • Required portions in the application.css and application.js files

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?

  • erb link tags in the app/views/application.html.erb

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>```

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

  • Fingerprinting is a technique that makes the name of a file dependent on the contents of the file. When the file contents change, the filename is also changed.
  • With each file update, a new hash string will be appended at the end of each asset file name. This process can force the browser to request the new updated files and eliminate browser caching the old asset issue.
@Carmer
Copy link

Carmer commented Apr 20, 2016

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? ----They are not the same becasue what we see within the browser is the concatenated file.

👍

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