Nice discovery: PJAX and Rails
Well this has been a discovery for me :-)
I finished my work early today and started my afternoon working through a simple iOS 5 tutorial. As recreation, I went over to Hacker News and read a linked article by David Heinemeier Hansson on making the response time fast on Basecamp Next while still doing mostly server side processing. The article and the comments were great.
This is of some interest to me because I have recently spent a lot of time writing a lot of client side Javascript for a Dojo + Rails app: straightforward but time consuming. DHH in the article and HN comments was making the point that for his company, it was a better developer experience doing more with server side Rails and less custom rich client code in Coffeescript or Javascript. I agree. He, and other people in the comments mentioned pjax as a library for sending back requests to the server that are marked with a HTTP header 'X-PJAX' if the page layout is not to be returned. This makes it relatively easy to still write mostly server side code but make page load times small when most or all of the page layout is not changed. Here is a simple Rails demo program by Edison Machado.
I need a few days to digest this, but this is likely going to change how I write Rails applications.
Hello Mark,
ReplyDeleteThis post is a great point about this great resource. The code example above uses the gem `pjax-rails` from DHH, that simplify many things. But instead, in a larger application, I use directly the Pjax javascript.
Besides the use in various GET forms and links, a great use case are paginations, I im using Pjax with `will_paginate`.
Anyway, now I see how is essential to create any application with Pjax. Speed up and saves many requests.
[]'s