Plugins - JavascriptRequire
Add to favoritesThis plugin allows dynamic inclusion of dependent javascript files at the application level. It does this by reading the first line of any javascript file and determining whether it is a ‘require’ line. Example:
// require prototype
var element = $('foo'); // prototype.js must be included before this file, so `$' etc are all available.
Recursive requires are supported, like so:
## student.js // require person ... ## person.js // require base ... ## base.js ...
In this case calling +javascript_include_tag(‘student’)+ will return:
The files to include are cached, so each file is only read once to determine its dependencies (unless you’re in development mode, then it is recomputed with each request).
NOTE: This has NOT been tested with using asset hosts (assets.example.com, Akamai, etc).
