My answer relates to Rails 3.1rc4, I donβt know if it will work with other versions.
You can put all the required statements in app / assets / javascripts / application.js regardless of whether the .js files are in app / assets / javascripts / or vendor / assets / javascripts /
Same:
// this is in app/assets/javascripts/application.js //= require modernizr-2.0 //= require jquery //= require jquery_ujs //= require jqueryui-1.8.12 //= require jquery.easing-1.3 //= require jquery.noisy //= require jquery.jslide-1.0 //= require respond //= require smoke //= require_tree
I have included require_tree here because I have other javascript files for my individual controllers (pages.js.coffee, users.js.coffee) and shared across the whole site (site.js.coffee)
Meanwhile, here is the file structure.
app/ βββ assets β βββ javascripts β β βββ application.js β β βββ pages.js.coffee β β βββ users.js.coffee β β βββ site.js.coffee β βββ stylesheets βββ plugins vendor/ βββ assets β βββ javascripts β β βββ jquery.easing-1.3.js β β βββ jquery.jslide-1.0.js β β βββ jquery.noisy.js β β βββ jqueryui-1.8.12.js β β βββ modernizr-2.0.js β β βββ respond.js β β βββ smoke.js β βββ stylesheets βββ plugins
This allows me to control the loading order of the provider libraries (which is very important, as a rule), and not to worry about my internal javascript, where the order is generally less.
More importantly, I control all the demanding statements in one frequently used file, I believe that it is safer and cleaner.
Olivier Lacan Jul 19 '11 at 3:15 a.m. 2011-07-19 15:15
source share