Friday, July 12, 2013

Rails - Javascript

From http://railsapps.github.io/rails-javascript-include-external.html

Rules of Thumb

In summary, here are rules of thumb to guide your use of JavaScript in Rails:
  • Logically organize your site-wide scripts in the app/assets/javascripts/ folder.
  • Copy external JavaScript libraries (such as jQuery plugins) to the vendor/assets/javascripts folder.
  • Let the Rails asset pipeline combine them all in one minimized application.js file.
  • List scripts in the app/assets/javascripts/application.js manifest.
In almost all applications, there is no need to add external JavaScript libraries directly in a view template. Use the Rails asset pipeline, even for JavaScript used on just one page (page-specific JavaScript). Copy external scripts to your application and you’ll gain the performance benefits of the Rails asset pipeline and avoid complexity.

No comments:

Post a Comment

Followers

Blog Archive