Live geek or die tryin'

Rails: Load Assets in a Specific Order

Let’s pretend you have many CSS/SASS stylesheets and JS/Coffee scripts in your project, and you want to load some before the rest. This can be done in stylesheets/application.css and javascripts/application.js by using the keyword require.

Examples:

Stylesheets:

If you want to load Bootstrap’s stylesheet first:

Javascripts:

This is how to load jQuery and Boostrap’s scripts before the others:

You can omit the files extensions.

I believe they call this the awesomeness of Rails.

Comments