Build a web application with ajax from the start or add ajax later?

I am working on my first Ruby on Rails utility, and it is quite large (at least for me;) - the database has about 25 tables). I am still learning Ruby and Rails, and I never wrote anything in Javascript or Ajax.

Should I add Ajax to my application from the very beginning? Or maybe it's better to add it last?

Or in other words: is it possible (relatively) easy to add ajax to an existing web application?

+7
ruby ajax ruby-on-rails
source share
3 answers

Depends on how important Ajax is to the application. Since you are probably going to use Ajax only for progressive usability improvements, I would say that it is best to start with traditional software without Ajax and add Ajax features only when you have the first features. You can perform this function by function or first write all the software and then start animating it.

Adding Ajax can be easier if you become familiar with unobtrusive JavaScript methods. Use jQuery instead of Prototype.js , or LowPro in addition to Prototype.js. For the latter, see, for example, the Jarkko Laine PDF book unobtrusive Prototype.js .

+4
source share

Jeremy Kate has written a wonderful article on this subject which he calls Hijax

In short:

  • Ajax planning from the start.
  • Embed Ajax at the end.
+11
source share

If you plan to do AJAX, I would do it from the very beginning. This will help you structure the actions and views of the controller, especially in terms of generating some data in partial views, right from the start. Knowing that some actions should be able to display only parts of the page will change your design. This does not mean that you cannot go back and modify the design, but I think it is easier to get the design right if you design it with this in mind. You should also consider how to make it work without AJAX (or javascript in general) so that your design is as safe as possible. This does not mean that all functions should be available, but this important functionality works in the absence of javascript. For example, action links that use AJAX should have a default URL that will trigger the correct action using a GET request if javascript is not enabled. Forms that are published through AJAX should also work if they publish normally. Dynamic behavior (e.g. image gallery) should have a useful alternative representation that works, etc.

+1
source share

All Articles