Skip to content

Instantly share code, notes, and snippets.

@jeneve
Last active April 20, 2016 15:47
Show Gist options
  • Save jeneve/af62b69be1c9181ee8b83ebc45d704df to your computer and use it in GitHub Desktop.
Save jeneve/af62b69be1c9181ee8b83ebc45d704df to your computer and use it in GitHub Desktop.

hat does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?

Reducing the number of requests is effective in optimizing a site because no matter how small the file is, every single request the browser makes takes at least 20 ms, and could take upwards of 100 ms or more. source What does it mean to precompile files? What does this have to do with coffeescript and sass files?

Precompile means to compile high level languages into base code that can be run. coffeescript compiles into javascript and sass complies into css. The asset pipline takes care of this but I'm not sure when.

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

Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually 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. source before and after minification

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?

on the local host, the code is compiled.

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

Sprockets uses manifest files to determine which assets to include and serve. These manifest files contain directives - instructions that tell Sprockets which files to require in order to build a single CSS or JavaScript file. With these directives, Sprockets loads the files specified, processes them if necessary, concatenates them into one single file and then compresses them (if Rails.application.config.assets.compress is true). By serving one file rather than many, the load time of pages can be greatly reduced because the browser makes fewer requests. Compression also reduces file size, enabling the browser to download them faster. source

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?

rails will look throughout the assets folder first, you can just give it the file name. In catch-em-all, this is happening with 'banner.png'

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

hmm.

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