Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 Pipeline - Exclude Javascript File

I want to exclude a particular javascript file (modernizr) from the pipeline because I want it to load separately.

I want to load Modernizr at the beginning and the rest of my javascript concatenated at the end.

Is there way to do the opposite of a require in the asset pipeline in 3.1? ie. an exclude?

Thanks in advance.

Adam.

like image 581
Adam Avatar asked Aug 15 '11 03:08

Adam


1 Answers

I chose to keep the sprockets functionality by changing

//= require_tree 

to

//= require_directory . 

This keeps sprockets auto-loading any files in the same directory, but not in any folders further.

This allowed me to move Modernizr.js to the assets/javascripts/top folder and manually load it at the top with:

<%= javascript_include_tag "top/modernizr" %> 

and move

<%= javascript_include_tag "application" %> 

To the bottom of my application.html.erb file (above the closing body tag)

like image 153
Adam Avatar answered Sep 20 '22 08:09

Adam