41

I have a js vendor script called Corners.js located in /vendor/assets/javascripts/ How do i include the js vendor script?

Casper larsen
  • 411
  • 1
  • 4
  • 3

1 Answers1

73

Just include

//= require Corners.js

in application.js and let the Rails to do the job for you (it automatically includes vendor/assets).

If you are just creating the vendor/assets/javascripts directory, you will need to restart your Rails server.

TALlama
  • 16,017
  • 8
  • 38
  • 47
Radim
  • 1,505
  • 10
  • 18
  • 5
    I had to restart `rails server`. Thanks for the suggestion. – soundly_typed Nov 21 '11 at 23:11
  • 3
    Won't it require the Corner.js file for every page of the application ? What if you need this file on 1 specific page and don't want to increase every page weight ? – Pierre-Adrien Mar 17 '12 at 10:49
  • 6
    Mark this as the answer please, he's absolutely correct. `application.js` won't catch anything in vendor with `//= require_tree .` – Jordan Scales Jun 10 '12 at 04:33
  • 2
    @LePad the resulting application.js will be compressed and it will be the same file for all the site's pages (so the user's browser can get it from its local cache). Also it will be the one and only javascript loaded by the application, so you'll have really good responsivity. – rewritten Oct 04 '12 at 11:11