Chronicling My Ruby on Rails Journey

Including Javascript

Posted by: Bob Ngu on: March 9, 2007

My RoR efforts have culminated in JiggyMe, check it out!

The simplest way to include Javascript is to add the following line

javascript_include_tag :defaults

That includes all the Javascript files though: application.js, controls.js, dragdrop.js, effects.js, prototype.js. All these files add about 150K(?) of code, so if you want to trim it down, you can specify the exact files you need instead of including all of them, e.g.,

javascript_include_tag "application", "prototype"

Leave a Reply