13.1. Introduction

The focus of this chapter is not on explaining JavaScript. The aim is to show you as a Rails programmer how you can integrate JavaScript in a Rails application. Correspondingly, the chapters do not explain JavaScript in detail. I am assuming that you can read and understand JavaScript. If not, it may be better to skip this chapter. You can happily get by without JavaScript.


By default, Rails 4 uses the jQuery Javascript library (http://jquery.com/). If you do not require this library, you should delete the following items from the file app/assets/javascripts/application.js within the asset pipeline (see Chapter 12, Asset Pipeline):
//= require jquery
//= require jquery_ujs
With jQuery, you can implement animations and Ajax interactions on your web page relatively easily.
You will find a good introduction to this topic in the jQuery documentation at http://learn.jquery.com/


For many Rails developers, CoffeeScript is the best thing invented since the introduction of sliced bread. CoffeeScript is a simple programming language that is converted to JavaScript via the asset pipeline. I am going to use JavaScript and CoffeeScript in this chapter. If you would like to know more about CoffeeScript, please look at the CoffeeScript documentation at http://coffeescript.org/ and as so often there is also an excellent Railscast on CoffeeScript available at http://railscasts.com/episodes/267-coffeescript-basics.

Thank you for your support and the visibility by linking to this website on Twitter and Facebook. That helps a lot!